cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lopezbec
Helper I
Helper I

Update File Properties Person/Group field when there are multiple selection

I have a flow that pulls approvers from a List based upon a department title.  I then create an approval request and send it to multiple people.  

 

I then want to update a file property called "Approval Sent to" (people/group picker that allows multiple selections)

I have tried using the Approvers Email and Display name and both of them fail to update this.  I have only had success with this update only when there is only one approver sent in my variable.

 

See the screen shots below.

 

To get the approvers, I do a select from the Get Items List and join it to a strVariable.

 

When I use that variable to update the file properties when it it only one person, it works.

lopezbec_0-1643401207062.png

 

the create approval will not use an object/array, so I created a string variable that uses the email to send the approval request.

How can I create something to update this file property ?  I will not know if there are 1 or 10 people this approval goes to.

 

Hope someone can help with this.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Let's start with the Approvers list. Flow is complaining that these users dont existing in your MS 365 tenancy. 

 

In the Update file properties "switch to input entire array" before specifying the value for Approval Sent to:

Snag_1906fce7.png

 Ellis

 

View solution in original post

19 REPLIES 19
lopezbec
Helper I
Helper I

 

 

Let me add more details.  If I send the Email for each user to this property, I get this error:

lopezbec_0-1643402419809.png

 

If I use the Approvers Display Name, I get this error:

lopezbec_1-1643402630842.png

Obviously, I know there is an issue with some of this syntax, but if the emails are valid users in the organization, why doesn't that work?

 

 

ekarim2020
Super User
Super User

Try the following format for a multi-select person column.

 

One person:

[
  {
    "Claims": "i:0#.f|membership|DiegoS@onmicrosoft.com"
  }
]

 

Multiple:

[
  {
    "Claims": "i:0#.f|membership|DiegoS@onmicrosoft.com"
  },
  {
    "Claims": "i:0#.f|membership|PradeepG@onmicrosoft.com"
  }
]

 

Snag_5181611.png

 


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

Thank you for your prompt input, I will try this when I return to the office on Monday. 

I just relooked at this.  This will not work, this updates a list, I am trying to update File Properties.

Any other ideas?

The same method will also work when updating file properties, for example:

Snag_9d4a877.png

 

Snag_9d8bb8e.png

Snag_9d95e75.png


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

I am still having an issue.  Not sure what you are using as the source for the compose statement.

 

I did it after the  create an approval, see output.

lopezbec_0-1643639817280.png

 

I then do an apply to each compose statement using the "Approvers Approver name" ,  It only is providing one name in the output even though there is an apply to each.

lopezbec_1-1643639881906.png

 

I also tried using in the apply to each with the others below:

 

1. "Approvers Item" with "Approvers All of the approvers" Get error:  

 
  "status"400,
  "message""The specified user [{\"id\":\"5b4d5f1c-4c0d-4b28-8c28-f9e242e5d22e\",\"displayName\":\"Laurie xxxxxx\",\"email\":\"xxxxx@xxxxx.com\",\"tenantId\":\"56c62bbe-8598-4b85-9e51-1ca753fa50f2\",\"userPrincipalName\":\"xxxxxx2@xxxxx.com\"},{\"id\":\"701fffd6-231f-4785-a4dd-40e5666062e7\",\"displayName\":\"Becca xxxxxx\",\"email\":\"xxxxxxxx@xxxxx.com\",\"tenantId\":\"56c62bbe-8598-4b85-9e51-1ca753fa50f2\",\"userPrincipalName\":\"Rxxxxxxx8@xxxxxx.com\"}] could not be found.\r\nclientRequestId: 735b87d5-64ab-4c2c-8b6c-ec81ec84bfb5\r\nserviceRequestId: 735b87d5-64ab-4c2c-8b6c-ec81ec84bfb5"
 

 

2. Approvers body with "Approvers All of the Approvers" I get this error: 

 
ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_8' failed: the result of the evaluation of 'foreach' expression '@body('Create_an_approval')' is of type 'Object'. The result must be a valid array.
 
3. Approvers body with Approvers Approver user principal name" and I get this error.
 
ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_8' failed: the result of the evaluation of 'foreach' expression '@body('Create_an_approval')' is of type 'Object'. The result must be a valid array.

 

Can you provide some more details on what I am missing?

 

This is the demo flow that I created. It updates file with SharePoint  ID = 3:

Snag_13805961.png

I have hard-coded the approvers in the Compose Multi action but you should be able to use the approvers' details in the flow.  Please share your flow.


Ellis

I get the approvers name from my list based upon the Department that is tied to my documents.

 

lopezbec_1-1643647905895.png

List:

lopezbec_2-1643647977566.png

 

lopezbec_0-1643647860709.png

I then get the Approver's email that is used for the "create an approval"

lopezbec_3-1643648043201.png

I then create an approval

lopezbec_4-1643648097946.png

After this Approval is created, it is after that step that I want to update the File Properties for my sharepoint document to include all of the approvers the create an approval was sent to.

 

 

 

Can you share your Get File(s) action, and where that fits into the flow:

Snag_13efaf84.png

 

Snag_13effb62.png

Ellis

Ignore the 10 that was placed, I removed that, it is now blank.

For the Get items for the Approvers email - this is used in the Create an Approval step.

lopezbec_3-1643654696111.png

I also get the display name because emails were not working for the file properties to update who the approvers were.

lopezbec_4-1643655269901.png

 

I was not able to use the variable to update the file properties and that is what initiated this original request.

Hopefully this makes sense.

 

After posting this, I do see it is creating two outputs for both approvers when I do the compose, the problem is that the update file properties with the first name and then updating it with the second name, not keeping both. If I try to move the update file properties outside of that apply to each, the output is no longer available.

Here is a demo flow I created, similar to your flow. Library A is a document library and there is an Approvers List based on Department:

Snag_148a7eed.png

This is the get files action to find documents that need to be reviewed: 

Snag_146cb8fa.png

Snag_146d7fc5.png

 

I'm using only one Apply to Each loop- and this works on each document that needs to be approved:

Snag_1478d811.png

Lookup the Department that was specified as a property for the document, then get the members of that department and their email addresses:

Snag_147a647d.png

 

Next Get the email addresses of each member of the department. Note the expression for the From field. There is only every going to be one record for each department in the Approvers list. The Get items - Approvers for Department returns one item and this item will be inside an array. We can just select the first item [0] from that array and we can use an expression to do this:

Snag_147d5905.png

 

outputs('Get_items_-_Approvers_for_Department')?['body/value']?[0]?['Approvers']
item()?['Email']

 

 

Join all the email addresses with a ';' so  that it can be used in an Approval action:

Snag_147f4b21.png

 

Like the email address, we can also get the properties (Claims) we need to set the "Approval Sent to" person column. Note the expression for the From field. Get items - Approvers for Department returns one item which will be inside an array. We can just select the first item [0] from that array and we can use an expression to do this:

Snag_14814d2a.png

 

outputs('Get_items_-_Approvers_for_Department')?['body/value']?[0]?['Approvers']
item()?['Claims']

 

 

Set the variable (the variable is not really needed, but you can refine the flow once it's working):

Snag_14834fd0.png

The Create Approval action:

Snag_14844174.png

 

Now update the "Approval Sent to" person column using the Claim properties we obtained in step (4):

Snag_149c635f.png

This is the sample runtime output:

Snag_149e6cbb.png

Hope this helps.


Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

lopezbec
Helper I
Helper I

Ellis, I appreciate all of this effort, but I am still having an issue.  I built it exactly has you have here, but I have some system differences that you will see below.  It is failing on the Create an approval, so it hasn't gotten to the Update file properties yet.  See below:

 

I have the trigger as When a file is create or modified because the Get items cannot be used as a trigger.

lopezbec_1-1643720825527.png

lopezbec_2-1643720843011.png

I get the file properties:

lopezbec_3-1643720970654.pnglopezbec_4-1643720989737.pnglopezbec_5-1643721017017.png

lopezbec_6-1643721047059.pnglopezbec_7-1643721075158.png

In the Select, I do not have the output to select, I had to manually enter this as a function.  Same with Email map.

lopezbec_8-1643721121665.png

 

lopezbec_9-1643721136506.pnglopezbec_10-1643721163356.png

The Select Claims again I had to manually enter the output and the item for claims. , it was not available to add

lopezbec_11-1643721200925.png

lopezbec_12-1643721224703.png

lopezbec_13-1643721260380.pnglopezbec_14-1643721279379.png

When running error received:  

I copied the output from each as I tested it.

lopezbec_15-1643721401892.png

lopezbec_16-1643721451709.png

 

Inputs from Select Email:

lopezbec_17-1643721764627.png

Outputs:

lopezbec_18-1643721818501.png

 

Join output has the : in the join.

lopezbec_19-1643721871462.png

Output from Select Claims

lopezbec_20-1643721923468.png

strApprovers Variable

lopezbec_21-1643721980018.png

 

 

 

 

For the Select action you will need to switch to text mode:

Snag_182233df.png

2022-02-01_13-53-05.gif

Ellis

Ok, that works, now when it is trying to update the file properties, this is happening:

 

first I get an warning before I test:

'Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself."

 

Error:

lopezbec_0-1643725582588.png

Select Claims, I had to manually add the output as a function

lopezbec_1-1643725670193.png

Same for the mapping of Claims item

lopezbec_2-1643725707820.pnglopezbec_3-1643725732250.png

 

 

 

lopezbec_4-1643725758547.png

lopezbec_5-1643725782770.png

 

 

 

 

You're going to need to set some trigger conditions so that the flow does not trigger itself each time you update the file properties.  For example, if the ReviewRequired column is true and the ApprovalSentTo column is empty:

 

Snag_18812ac9.png

  

Snag_18841619.png

Here is an updated flow, based on the new trigger and trigger conditions:

ekarim2020_2-1643730953956.png

ekarim2020_3-1643730992186.png

 

ekarim2020_4-1643731023638.png

ekarim2020_0-1643739460027.png

 

 

Ellis

lopezbec
Helper I
Helper I

The Create Approval works and sends it out, but the Select claims and Update file properties are still an issue, see screen shots below:

 

Trigger, I added conditions, but I still get this message in Flow Checker:

lopezbec_0-1643736462786.png

Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.

 

Claims Select, again, I had to enter the functions manually, the output was not available.  It doesn't like something here.

lopezbec_1-1643736552013.png

lopezbec_2-1643736577075.pnglopezbec_3-1643736598570.png

 

lopezbec_4-1643736631750.pnglopezbec_5-1643736652454.png

Error received from Update File Properties:

lopezbec_7-1643736779856.png

 

Output

lopezbec_6-1643736711651.png

 

 

 

Let's start with the Approvers list. Flow is complaining that these users dont existing in your MS 365 tenancy. 

 

In the Update file properties "switch to input entire array" before specifying the value for Approval Sent to:

Snag_1906fce7.png

 Ellis

 

That did it.  THANK YOU!!!! So much.  For those that see this later, there is multiple strings of responses you need to look at to make this work.  Ellis - you are a great resource and I appreciate all you have done to help me out!!!  Kudos.

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 (4,356)