Use Power Automate to Change Creator, Created on, Last Modified on and Modified by in a SharePoint List Item or Document Item

This is courtesy of the following authors. They got it all there but I’m putting it here on my personal blog for future reference and quicker for me to copy. Read the comments in their post as they have pointed a lot of improvements to it.

MVP John Liu: https://johnliu.net/blog/2019/2/flowninja-hack-78-modifying-modified-by-and-modified-time-with-microsoft-flow

MVP Andrew Koltyakov – https://www.linkedin.com/pulse/list-items-system-update-options-sharepoint-online-andrew-koltyakov/

Use case:

Maybe for compliance stuff? One day you may have find yourself that you need to recreate a table because when you copied it the modified dates and names have changed or maybe you just want to make subtle changes to the row information without affecting the modified date/name. For whatever reason you have to this, here’s how you can do it:

So whole the process:

  1. Make sure that the user who run the flow has OWNER access to the SharePoint Site
  2. Action Card: Compose User Claim
  3. Action Card: Compose Form Values
    • Make sure User Claims is in String
    • Make sure Dates are in the proper format: ‘yyyy-MM-dd HH:mm:ss’
  4. Send an HTTP request to SharePoint

So some screenshots cause (i know) words are just too difficult to follow:

For Step 1

Creator Mail here should be something like [email protected]

Option A

[
  {
    "Key": "i:0#.f|membership|@{items('Apply_to_each_2')?['CreatorEmail']}"
  }
]
JavaScript
[
  {
    "Key": "i:0#.f|membership|[email protected]"
  }
]
JavaScript

Code for updated Modified on and Modified By

[
  {
    "FieldName": "Editor", 
    "FieldValue": @{string(outputs('Compose_User_Claim'))}
  },
  {
    "FieldName": "Modified",
    "FieldValue": "@{formatDateTime(utcNow(), 'yyyy-MM-dd HH:mm:ss')}"
  }
]
JavaScript

Code for updated Created on and Created By

[
  {
    "FieldName": "Author", 
    "FieldValue": @{string(outputs('Compose_User_Claim'))}
  },
  {
    "FieldName": "Created",
    "FieldValue": "@{formatDateTime(utcNow(), 'yyyy-MM-dd HH:mm:ss')}"
  }
]
JavaScript
//FOR URI
_api/web/lists/getbytitle('List Name')/@{ID}/validateUpdateListItem

//FOR BODY
{
  "formValues": @{outputs('Compose_Form_Values')},
  "bNewDocumentUpdate": false
}
JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *