I am using flow to upload a document to a sharepoint list. One of the metadata to accompany the file contain a Office365 user or group field.
However when I try to run the flow, all the other metadata fields work and the file uploads but I get an error on the Office365 user field. I wonder am I using the wrong variable type (string).Here is the flow action:
And here is the variable is referenced in the Update file properties action:
And here is the error:
Solved! Go to Solution.
Hi @Boppersnr,
It looks like the correct claims data is coming from PowerApps. The formula in PowerApps should be correct.
Now, we can focus on the Power Automate flow. Your input is still in a comma separated string format.
We want to change that to a claims array. You can use a select action for this. After that you can switch the person field to input an entire array and use the outputs in your person field.
Below is an example of that approach.
1. Add a Select action directly after your Initialize variable/varTrainingRequirements variable action. Use the expression below in the From field.
split(variables('varTrainingRequirements'), ',')
Map the Claims to the item()
2. The outputs of that action will look something like below.
3. Go to your update file properties action. Switch the input to entire array by click the T button.
4. Use the Output of Select action.
Hi @Boppersnr,
A claims field for a user normally expects a value something like this:
i:0#.f|membership|johndoe@contoso.onmicrosoft.com
Is see you are trying to input the user displayName. Do you know the UPN or email of the users? If so, you could combine it into a valid claims value by using concat function in an expression.
ok, cool.
Where would I input the concat expression. is it somewhere in the flow or in the powerapps screen where I run the flow from?
I changed the powerapps screen field to DisplayName from Claims.
Here is my flow run button code: UploadUsertoSharePointList.Run(Last(AttachmentControl.Attachments).Name,varBase64Only,Concat(TrainingRequirements.SelectedItems,DisplayName&", ")
But I still get the error:
I also changed the Flow Run command to claims (instead of DisplayName), but I get this;
Flow run command: UploadUsertoSharePointList.Run(Last(AttachmentControl.Attachments).Name,varBase64Only,Concat(TrainingRequirements.SelectedItems,Claims&", ")
Hi @Boppersnr,
That second attempt with the Claims looks better. However, I see in your PowerApps formula you are concatenating even though it is only a single user?
I think you need to trim the last two characters of the last item of your list of selected items. The PowerApps documentation has an example for that:
In your case that would be probably something like this:
UploadUsertoSharePointList.Run(Last(AttachmentControl.Attachments).Name,varBase64Only,Left(Concat(TrainingRequirements.SelectedItems,Claims&", "), Len(Concat(TrainingRequirements.SelectedItems,Claims&", ")) -2))
@Expiscornovus yes, that code worked when I made the TrainingRequirements field a single user entry but in this case I want to be able to set it to accept multiple name entries. What code would I need to do to allow more than 1 username
(DisplayName)?
See error when I make the field to allow multiple selections:
I wonder is it something to do with when I create the variable for it, I have it set as a string, but it wont work if I change to Object or Array either. I get different errors and it wont even import as a flow when I change to that.
@Expiscornovus I just deleted a few of the actions in the flow and recreated them and it worked when I input 1 user. but when I add more than 1 I get this error:
I guess the code isn't taking into account they are separate entries (users). How can I create flow code to allow multiple entries in a User/Group field?
Hi @Boppersnr,
It looks like the correct claims data is coming from PowerApps. The formula in PowerApps should be correct.
Now, we can focus on the Power Automate flow. Your input is still in a comma separated string format.
We want to change that to a claims array. You can use a select action for this. After that you can switch the person field to input an entire array and use the outputs in your person field.
Below is an example of that approach.
1. Add a Select action directly after your Initialize variable/varTrainingRequirements variable action. Use the expression below in the From field.
split(variables('varTrainingRequirements'), ',')
Map the Claims to the item()
2. The outputs of that action will look something like below.
3. Go to your update file properties action. Switch the input to entire array by click the T button.
4. Use the Output of Select action.
User | Count |
---|---|
87 | |
37 | |
25 | |
13 | |
12 |
User | Count |
---|---|
117 | |
55 | |
36 | |
23 | |
21 |