cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lui
Helper IV
Helper IV

Pass a blank value to a person field in an expression

Hello. I have conditions in an expression for a person field but I want to make the false result as blank. 
I've tried the following but still getting the same error (user not found)

 

If(Or(equals(triggerBody()?['Step_Name'], 'ABC Review')),triggerBody()?['Person1']?['Claims'],If(Or(equals(triggerBody()?['Step_Name'], 'DEF Review')), triggerBody()?['Person2']?['Claims'],''))

 

If(Or(equals(triggerBody()?['Step_Name'], 'ABC Review')),triggerBody()?['Person1']?['Claims'],If(Or(equals(triggerBody()?['Step_Name'], 'DEF Review')), triggerBody()?['Person2']?['Claims'],null))

 

If(Or(equals(triggerBody()?['Step_Name'], 'ABC Review')),triggerBody()?['Person1']?['Claims'],If(Or(equals(triggerBody()?['Step_Name'], 'DEF Review')), triggerBody()?['Person2']?['Claims'],-1))

 

Any suggestions?  thank you ahead

1 ACCEPTED SOLUTION

Accepted Solutions
DanyElHoyek
Advocate IV
Advocate IV

You can solve the issue by using Send http request to SharePoint to update your item. Please note that using Update Item action will not work in case of Multiple value people field, therefore it is best to use the Send http request to SharePoint when you want to clear the value of a people field.

 

The method used in the below article will work

https://jobs.collab365.community/how-to-update-the-sharepoint-people-picker-field-using-power-automa...

 

In short:

it is important to mention that when using REST API, the People and Group field will be returned as “FieldNameId”. The format for user field value:
  • single-valued user field: ‘<user field name>Id’ : <user id>
  • multi-valued user field: ‘<user field name>Id’ : { ‘results’: [<array of user ids>] }

    To empty the fields
  • single-valued user field: ‘<user field name>Id’ : -1
  • multi-valued user field: ‘<user field name>Id’ : { ‘results’: [0] }

You need to get the id of the user as stated in the article and then update you expression accordingly.

Let me know if you require any details. but it will solve you a lot of trouble to use this method

 

View solution in original post

8 REPLIES 8
v-litu-msft
Community Support
Community Support

Hi @lui,

 

It seems like have some logic error in your expression, the structure of or() function is or(expression1, expression2, ...)

You can try to test the following expression firstly:

if(equals(triggerBody()?['Step_Name'], 'DEF Review'), triggerBody()?['Person2']?['Claims'],null)

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-litu-msft Well right now, i have the following expression and it works fine:

 

If(Or(equals(triggerBody()?['Step_Name'], 'ABC Review')),triggerBody()?['Person1']?['Claims'],If(Or(equals(triggerBody()?['Step_Name'], 'DEF Review')), triggerBody()?['Person2']?['Claims'],triggerBody()?['Person2']?['Claims']))

 

I want to replace the false result (in bold) to a blank value. If I replace the bold section with null it doesnt work. What do you suggest?

 

v-litu-msft
Community Support
Community Support

Hi @lui,

 

Please have a try the following expression:

If(Or(equals(triggerBody()?['Step_Name'], 'ABC Review')),triggerBody()?['Person1']?['Claims'],If(Or(equals(triggerBody()?['Step_Name'], 'DEF Review')), triggerBody()?['Person2']?['Claims'],if(equals(triggerBody()?['Person2']?['Claims'],null),false)))

 

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-litu-msft  entering "false" did not work.  This is the error I keep receiving when i tried null, false, -1

 

{
"status": 400,
"message": "The specified user False could not be found.\r\nclientRequestId: bef4\r\nserviceRequestId: bef"
}
 
How do i create a new item with a blank value? 
v-litu-msft
Community Support
Community Support

Hi @lui,

 

How about using a Blank character: " "?

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I've tried , '') but it doesnt work. Im running out of options! There must be a way to have a blank result when using conditions.

DanyElHoyek
Advocate IV
Advocate IV

You can solve the issue by using Send http request to SharePoint to update your item. Please note that using Update Item action will not work in case of Multiple value people field, therefore it is best to use the Send http request to SharePoint when you want to clear the value of a people field.

 

The method used in the below article will work

https://jobs.collab365.community/how-to-update-the-sharepoint-people-picker-field-using-power-automa...

 

In short:

it is important to mention that when using REST API, the People and Group field will be returned as “FieldNameId”. The format for user field value:
  • single-valued user field: ‘<user field name>Id’ : <user id>
  • multi-valued user field: ‘<user field name>Id’ : { ‘results’: [<array of user ids>] }

    To empty the fields
  • single-valued user field: ‘<user field name>Id’ : -1
  • multi-valued user field: ‘<user field name>Id’ : { ‘results’: [0] }

You need to get the id of the user as stated in the article and then update you expression accordingly.

Let me know if you require any details. but it will solve you a lot of trouble to use this method

 

Risi
Frequent Visitor

Looks like I'm a year late replying to this. In Short the right answer is to use "Send http request to SharePoint " the problem with that answer is that it's not sexy compared to using the "Create Item" and "Update Item" actions. 

 

I did come to a solution that can help some.

 

In scenarios where the Claims were empty, I would add a conditional Update Item right after creating the item.

If the Claim wasn't empty I would trigger the update. If it was empty I wouldn't trigger the update.

 

This is a solution until Microsoft improves the "Create Item" and "Update Item" actions

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,991)