Forum Discussion

Texas_Technician's avatar
Texas_Technician
Copper Contributor
Nov 09, 2022
Solved

Update 'Created By' and 'Modified By' fields.

I built an app with a few flows which manage a document library in SPO.  But of course every item in the list has the flow creator's credentials as the author.   I've figured out how to disable "Re...
  • RobElliott's avatar
    Nov 09, 2022

    Texas_Technician hopefully I can add to what @ganeshsanap has pointed you towards to show you what we do in my company. In way you've asked 2 different questions: 1) Changing the Created By (Author) column and 2) running a flow as another user.

     

    1) Changing the Created By (Author) column

     

    We do this on our intranet to change the Created by column to the contact named in a news story. This is so that any comments go to the contact (rather the person who actually crteated the page (usually me). So this is being done on the Site Pages library but would work equally well on a documents library. It needs 

     

    The flow is as follows:

     

    In the above send an http request action the uri field is:


    _api/web/lists/getByTitle('Site Pages')/items(@{triggerBody()?['entity']?['ID']})/validateUpdateListItem

    and the Body field has the following:

     

    {
    "formValues":[
    {
    "FieldName": "Author",
    "FieldValue": "[{'Key':'i:0#.f|membership|p@{triggerBody()['number']}@capita.co.uk'}]"
    },
    {
    "FieldName": "Editor",
    "FieldValue": "[{'Key':'i:0#.f|membership|p@{triggerBody()['number']}@capita.co.uk'}]"
    }
    ],
    "bNewDocumentUpdate": true
    }

     

    The library is shown below:

     

    When the red button in the list is pressed the flow pane opens and I enter the employee number of the new author:

     

    To create the button, in the library add a single line of text column and format the column in advanced mode with the following JSON, changing the ID to the ID of your flow and changing text or other style attributes as necessary:

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "button",
      "txtContent": "Change Created By to name of page contact",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "{\"id\": \"50097cde-b800-4c6c-ade9-95be7574f4e5\",\"headerText\":\"Change Author to Contact\",\"runFlowButtonText\":\"Go\"}"
      },
      "style": {
        "background-color": "#cf000f",
        "color": "white",
        "border-radius": "10px"
      }
    }

     

    2) running a flow as another user

     

    No, this isn't possible as the flow uses your connections. Depending what you want to do, for example send an email, you could either use a shared mailbox, use the send an email notification (v3) which sends it from Microsoft or trigger it from a Power App button. For this last one your flow would need a Power Apps (v2) trigger and it would send the email from the user clicking it, not from you.

     

     

    Hope that hives you something to think about.

     

    Rob
    Los Gallardos
    Intranet, SharePoint and Power Platform Manager (and classic 1967 Morris Traveller driver)

     

Resources