Problem : Suppose we have a power automate / flow that gets triggered when a SharePoint online list gets created / updated and the flow performs some action that updates the list. If we observe the Modified By column of the List, it can be observed that the Modified By column reflects the account/user under which the flow is running rather than the user whose action (create/update) triggered the flow.
We have created a List as displayed below :
We have designed a sample Flow that updates the Email field and corresponding the Modified By column also gets updated with the System account under which the flow is running, which in this case is my account.
Now to enable the Modified By column to show the user name who triggered the flow, we have to make certain changes.
- Use a Compose shape to set the Key for the User Account that triggered the shape as shown in the image below :
[{"Key": "i:0#.f|membership|username@yourcompany.com"}]
- Use another Compose shape dependent on the output of the above compose shape to generate the formValues to be used in a a JSON format later.
a.
b.
[
{
"FieldName" : "Editor"
"FieldValue" : @{concat(outputs('Compose_User_Modified'))}
}
]
Finally
- An update item call is made to the SharePoint item in the List, make an additional call to the SharePoint using the shape "Send an HTTP request to SharePoint"
This will be POST call where the Body consists of the JSON format.
The formValues shall consist of the Name Value pairs, in our case we are setting the Key as Editor.
Sample format :
{
"formValues": [
{ "FieldName": "Title",
"FieldValue": "Item"
}
],
"bNewDocumentUpdate": false
}
The flag bNewDocumentUpdate is set as false so as not to create a new version on top of the one created by the flow. The false flag effectively overwrites the entry of the Modified By field by the flow with that of the user triggering the flow.
With the above mentioned changes in place we are good to go. Hope this helps in case you need to set the Modified By field correctly while updating your share point list.
Reference : John Liu
Top comments (0)