Top
PowerApps

Clear lookup and people picker fields in PowerApps


Have you ever been struggling with a lack of the possibility to clear a number, person or lookup column using PowerApps? Well, I recently found myself in a situation, where I needed to be able to clear such columns in my application, but found out, that this is not possible (maybe not yet).

I was trying every approach I could think of – setting blank values, using empty object for lookup:

{
  '@odata.type' : "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
  Id: 0,
  Value: null
}

and peoplepicker but none of them worked. When I thought this is impossible I reminded myself about the tight integration between PowerApps and Microsoft Flow.

The solution

Using Flow triggered by clicking a button (or by other action) it turned out to be very easy. Simply – go to the “actions” tab (1), select Flow (2). Select the button you want to bind with the Flow (3). Next click to create a new one (4). After that create a single action: “Call HTTP endpoint in SharePoint”. Then select the created Flow (5) and pass arguments to it (6):

Prepare Flow for button click in PowerApps

Simple "PowerApps button" Flow

Why? I found out, that using the regular “Update item” action does not allow to clear lookup and person fields as well (uh!), moreover there is no action to update a single field in a record (again, not yet), so first you would need to query that list item, get its data and rewrite it to the update action, so that it won’t wipe out all other fields as well. A lot of work, as you need to update a single field.

The configuration of the “Call HTTP endpoint in SharePoint” action is as below (note, this is a new action in Flow and is extremely useful, as you don’t need to use HTTP request action, grant it OAuth permissions or make a trust in SharePoint. Simple and easy):

Send an HTTP Request to SharePoint

[tds_info]To obtain “type” value do a test call to /_api/Web/Lists/GetByTitle(‘List Name’)?$select=ListItemEntityTypeFullName and get value returned by ListItemEntityTypeFullName attribute. What is also important is that lookup fields (lookup, person) must have their internal names followed by “Id”.[/tds_info]

Then you can add the “Return to PowerApps” action, so that you can make a sequence of events in PowerApps or return some information back to your application.

It really works like a charm!

PowerApps and Flow clearing fields in SharePoint


Tomasz Poszytek

Hi, I am Tomasz. I am expert in the field of process automation and business solutions' building using Power Platform. I am Microsoft MVP and Nintex vTE.

12 Comments
  • Josh Nystrom

    Hi Tomasz,

    I have a seemingly reliable update to this process (At least for Person picker SP fields). You mention trying “setting blank values, using empty object for lookup[…]” for which your exact approach is not clear, so possibly you tried this way in the past.

    The way your HTTP Request body is written is very similar to what I’d been using previously:
    {
    “__metadata”:{“type”: “SP.Data.MyListListItem”},
    “StaffFieldId”:{“results”: [0]}
    }
    but it helped me see a different approach available within PowerApps.

    All I’ve done is set a “BlankPerson” variable that is manually shaped as a single, blanked-out Person record for the SP Person/Group field, as follows:

    Set(BlankPerson,Table({‘@odata.type’:”#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser”,Claims:Blank(),DisplayName:Blank(),Email:Blank(),Department:Blank(),Picture:Blank(),JobTitle:Blank()}))

    When Patching with this as my payload when the People picker control is left blank, I’ve been able to Clear the corresponding field on my SP List item.

    My current understanding of my approach makes a few assumptions (I’m not certain whether they are integral to its use):

    -You are treating this like a “Complex” data update and are therefore using Patch statements to merge into the existing SP List item
    -Your app has a way to detect when the person-picking control was left blank so that you can conditionally change which Patch statement is being executed
    -You are using the out-of-the-box people picker or can otherwise tweak my approach to match a “valueless” Person record

    As mentioned, I’m not sure if this works for LookUp fields, but I hope it helps move this challenge along.

    Cheers!
    Josh

    March 11, 2019 at 6:00 pm Reply
    • Tomasz Poszytek

      Hi Josh! Thanks for sharing, This is always very valuable to see others’ solutions.

      Just a small remark – my approach for setting blank values was to use the following complex data type:
      {
      ‘@odata.type’ : “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,
      Id: 0,
      Value: null
      }
      But it didn’t work 🙂 Therefore I moved to Flow and managed to clear these fields using Flow actions.

      March 13, 2019 at 8:49 am Reply
  • Gabriel Venancio

    Hi My Brother!!!

    {
    Id: -1;
    Value: Blank()
    }
    this works.
    Test there!!!

    October 28, 2019 at 6:43 pm Reply
    • Tomasz Poszytek

      Awesome to hear it! 🙂

      October 28, 2019 at 11:21 pm Reply
    • Maja Olesen

      Gabriel, did you get that to clear the people picker on the SharePoint list?
      Does it work with submit form or must i be a patch?

      February 25, 2020 at 1:26 pm Reply
  • Damian

    Works well
    User:{
    ‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser”,
    Claims: Blank(),
    Department: Blank(),
    DisplayName: Blank(),
    Email: Blank(),
    JobTitle: Blank(),
    Picture: Blank()
    }

    October 6, 2020 at 9:53 am Reply
  • Holger Hagedorn

    I tried this with Patch an in the Update method of the DataCard, no success.
    Do you have an idea, why it does not work?
    {
    ‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser”,
    Claims: Blank(),
    Department: Blank(),
    DisplayName: Blank(),
    Email: Blank(),
    JobTitle: Blank(),
    Picture: Blank()
    }

    January 4, 2021 at 12:04 am Reply
    • Tomasz Poszytek

      Because you are trying to save a person object with all properties “blank”. Not a blank object. Maybe simple {} would work?

      January 23, 2021 at 1:47 am Reply
  • Dennis K

    Gabriel Venancio, YOU LEGNED!!! Thank-you so so much!!! Bloody brilliant.

    May 14, 2021 at 11:06 am Reply
  • Jake Mannion

    Thanks for this solution! Was having trouble clearing person values from the PowerApp side – this was a foolproof (and easy) way to clean up item data from the Automate side. Much appreciated!!

    August 20, 2021 at 7:47 pm Reply

Post a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.