Power Apps
Power Apps,  Power Platform

How to delete person in SharePoint Power Apps form?

Today, I have seen one more interesting issue in SharePoint Power Apps Form. I have customized SharePoint form in Power Apps. It is working perfectly except it is not patching person data when I removed person from people picker field.

Then I came to point that one more thing is missed from Microsoft. After reading lots of posts (including microsoft community) I felt like to write complete step by step solution for this issue (or you may say bug).

This is known issue. Even if your Formula-level prefetching setting is enabled in power Apps settings, this issue will still come-

Prefetching

Though there are two ways to fix this issue

  • MS flow
  • Power apps experimental features. 

So this is our issue-

peoplepicker

Solution-1

We need to attach one flow with Power Apps form. You can decide how you will trigger this flow. Here I am using Trash icon select property to trigger my flow.

Step-1: Open your SharePoint list(My list: People Picker Test) form in Power Apps editor and add one icon ‘Trash’ in Person card. Arrange icon size and location based on your requirement.

Trash Icon

Step-2: Now, Select your ‘Trash’ icon and click on Action->Power Automate->Create a new flow.

Step-3: It will take you to Power Automate portal where you can click on +Create and choose ‘Automated Cloud Flow‘. Click on Skip and move directly to Flow editor page.

Step-4: On flow editor page add following steps-

Steps

Following is detailed flow steps from above screen

Step1

Flow

 

Step-5: Now save your flow and go back to power Apps editor and click on Flow name under Data tab. This will add your flow on Icon Select  
FLow-Apps
 

Step-6: I have added list item id as 1 to check whether my flow is working fine or not. See PeoplePickerTest.Run(1) – I passed list item ID as 1 here.

To make this dynamic we need to add list id in our power Apps form and later we made this card visible property ‘false’. I used following-PeoplePickerTest.Run(DataCardValue4.Text).
Power Apps

Step-7: Save your Power Apps Form & Publish it.
Additional input 1– After clicking on ‘Trash’ icon you will see your list person field updated in backend but Person data Data Card is still showing Person display name.
CLeanPerson
 
To clear this field,  we need to define one variable and based on this variable we can clean person display name in Power Apps form. Here I defined  variable VarClean as Set(VarClean,true) in icon onSelect property.
 
DefineVar
Now I have set my Person data card DefaultSelectedItems property as-If(VarClean=true,Blank(),Parent.default)
Set Var
 
Now you can see when we click on ‘Trash’ icon, Person field in form & list are updating simultaneously.
 
Output
Additional Input 2– Here Trash icon is visible irrespective of form mode. You can make this icon visible only when form is in Edit mode. To do so use following Power Fx in icon visible property- If(SharePointForm1.Mode=FormMode.Edit,true,false).
 

Solution-2

There is another experimental feature which we need to enable and this issue will resolve. In Power Apps setting page enable Formula-level error management option then save and publish your app. 
 
PA setting
 
Both these solution will work though I like Solution-1 as this one is a solid approach but for solution-2 proceed with a little caution. This is power app experimental feature and these features may change in future. you need to keep a close eye on such changes in Power Apps.
 
-Gopenly Team

2 Comments

Leave a Reply