cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Clearing out people picker field

I've customized the default form for a SharePoint list using PA - the form is used for people in my organisation to book slots on a training course. It's a simple list and users can only edit two fields; Name (people picker) and Status (DDL either Vacant or Booked). Everything works well until someone wants to cancel their slot and remove their name. When clearing out the Name field and hitting Save, the field is repopulated with the name that was originally saved there. The name can be overwritten with a new value, but it can't seemingly be deleted. Has anyone else experienced this or found a way to solve it? Thanks
25 REPLIES 25

@sjcitpro,

Yeah, that's how I was doing it before I started down this path. However, when I started rebuilding my App from scratch, I decided I wanted to avoid the Flow. In my previous build, I was relying on rough-guess timers to be able to accurately navigate screens based on Flow successes/failures - perhaps unnecessarily?

Thankfully my Person field is a People field... again, hopefully we get general availability of patching-to-null soon.

Cheers,

Josh

Hi josh not sure why it didn’t work for me, the patch to people field looks for a record not a table so it didn’t work but just changing your code a little it worked a charm! Thanks

Patch(testlist,
ID:ItemID,{personfield:Lookup(blankperson,Claims=blank())}
)

Works a treat
Anonymous
Not applicable

In case anyone finds their way here. I think they made some changes to PowerApps that now allow the Blank() function to patch a blank value to people picker fields. You do need to have the experimental feature turned on though.

 

In my case, I was trying to clear the value from a single select People Picker in order to return an item to a general queue where it could be reclaimed by another. I was working with the items inside of a gallery, so you may have to alter it to fit what you need. What ended up working was:

 

Patch(YourListName, ThisItem, {PeoplePickerFieldName: Blank()})

 

This cleared the people picker value and reset it to blank

When i tested with your approach i am geeing the below error
The type of argument AssignedTo does not match the expected type record.Found type is table

Hey @santukondapally,

 

That error message appears when you try to patch a SharePoint person column that supports entry of a single person using a table-based "BlankPeople" format (I've finally gone back to clarify in my old posts that they are "BlankPeople" not "BlankPerson" patches).

 

In your case, you may need "AssignedTo" to remain as a single person field, which means that for now, you will need to rely on enabling the Experimental Feature shown in the first part of my other post here (remember to reload your app editor after turning it on) - https://powerusers.microsoft.com/t5/Building-Power-Apps/Clearing-out-people-picker-field/m-p/262739/...  

Once that feature is enabled, your patch should work with something along these lines:

Set(
    BlankPerson,
        {
            Claims: Blank(),
            DisplayName: Blank(),
            Email: Blank(),
            Department: Blank(),
            Picture: Blank(),
            JobTitle: Blank()
        }
);

 

Patch(
        'Your list',
        {ID: ItemID},
        {
	    AssignedTo: BlankPerson
        }
    )

 Be sure to note that this "BlankPerson" variable does not have the Table function wrapping its contents, meaning it is now a "record" and the error won't occur when trying to patch "AssignedTo". As far as I know, enabling the "Formula-level error management" Experimental Feature is still necessary for SharePoint to clear the field as expected.

 

Hope this helps!

Josh

New Member

Hi there,

 

This is a great post. I've been able to use your concept to run the patch function as part of an OnSelect code related to a button on the edit form. This works fine and clears my value for the selected record. I'm a bit new to PowerApps though and was wondering if there's a clean way to run it as part of the update code for when the edit form is actually being saved? In that way run the regular update statements as part of the bound data and then following that detect that the passed value was a blank and as a result run the patch? Seems like this should be obvious and I'm just missing something!

 

Any updates are helpful!

Nick

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (9,513)