How to update editor and author fields in SharePoint using Power Automate
Power Automate will run under owner connection or we can change the connection for a specific action. So when an update item or create item action is used in the flow, the “created by” or “modified by” will be updated by owner name or whoever name is configured in the connection instead of the current user who triggered the flow.
To overcome this issue we can use “validateUpdateListItem” a Rest API method available in SharePoint, which can be used to update the items. Using this method we can update all the metadata fields like Author, Editor, Created and Modified.
We have to pass data that needs to be updated in JSON format, to update the picker columns the values should be constructed as JSON then it should be converted to a string.
To update the date and time field it should be in the “yyyy-MM-dd hh:mm:ss” format.
The output of ComposeJSON should be passed to “formValues”
Here we are passing the “Modified By Claims” value to the “Editor” column, It will update the name of one who triggered the workflow instead of the “Connection user”
The above steps can be converted to one step if you like to keep things messy.
//Rest API url
/_api/web/lists/GetByTitle('Infinite Loop')/items(@{triggerOutputs()?['body/ID']})/validateUpdateListItem
//Body
{
"formValues":[
{"FieldName":"Title","FieldValue":"Rest API Test"},
{"FieldName":"Editor","FieldValue":"[{\"Key\": \"@{triggerOutputs()?['body/Editor/Claims']}\"}]"},
{"FieldName":"Modified","FieldValue":"@{formatDateTime(triggerOutputs()?['body/Modified'],'M/D/YYYY h:m A')}"}
],
"bNewDocumentUpdate": true
}
If “bNewDocumentUpdate” is false it will create a version otherwise it will not create one.
In this example, we are updating with false, and a new version 64 is created.
In this example we are updating with true here the version is not created after 65.
If we need to replace the Modified By and Created By with a different user then we have to pass a claims value of that user like below.
i:0#.f|membership|user@organization.com
This method acted as a “System update” if we pass the same “Modified By”, “Modifed” and prevented infinite loops previously. But it is not working anymore, it triggers the flow.
To do a workaround on infinite loop check out our other posts.
Please post your queries in the comments. Happy Building š