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?

 

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? 

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,988)