cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Responsive Resident
Responsive Resident

Is it possible to get the ID of a person who has activated the flow?

Hello, 

Hope everyone is well.


I am trying to create unique IDs with users' names and wondered, if the following solution is possible to accomplish with Power Automate?

1. User A is logged to a SharePoint site;

2. User A clicks Power Automate button in the SharePoint list to active the flow;

3. Power Automate recognizes that it was activated by User A and saves user's name and surname, for example.

 

Would sincerely appreciate an advice. 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User II
Super User II

Hi @mantastg08876,

 

Just to validate. With activate you mean who triggered an existing flow on the list? If yes, this should be possible. You can get the user name of the identity which triggered the flow from the headers.

 

Below is a small example to demonstrate.

 

1. Create a flow with the SharePoint For a selected item trigger. Configure it to use a specific list, in this case Captureuser

captureuser.png

2. Add a Compose action and add the following expression to it:

 

triggerOutputs()['headers']['x-ms-user-name']

 

 

xmsusernameheader.png

 

3. Make a Note of your flow Id

flowidusername.png

 4. Add a button to your list, in this case the CaptureUser list. Create a column called Button (type single line of text). Add the following json to it and replace the flow id by your flow id. This way you can click that button and trigger your flow.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"5086d422-c666-4840-bbb1-bb894fc59d20\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "PowerButton"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": ""
    }
  ]
}

 

formatcolumnsharepoint.png

View solution in original post

Super User II
Super User II

Hi @mantastg08876,

 

No, I mean the Response Headers from the trigger action in the Power Automate Flow. The flow is aware who triggered it.

 

You can extract that information from one of the properties of the Response Header, in this example either x-ms-user-name or x-ms-user-email.

 

triggerhttpresponseheaders.png

View solution in original post

4 REPLIES 4
Super User II
Super User II

Hi @mantastg08876,

 

Just to validate. With activate you mean who triggered an existing flow on the list? If yes, this should be possible. You can get the user name of the identity which triggered the flow from the headers.

 

Below is a small example to demonstrate.

 

1. Create a flow with the SharePoint For a selected item trigger. Configure it to use a specific list, in this case Captureuser

captureuser.png

2. Add a Compose action and add the following expression to it:

 

triggerOutputs()['headers']['x-ms-user-name']

 

 

xmsusernameheader.png

 

3. Make a Note of your flow Id

flowidusername.png

 4. Add a button to your list, in this case the CaptureUser list. Create a column called Button (type single line of text). Add the following json to it and replace the flow id by your flow id. This way you can click that button and trigger your flow.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"5086d422-c666-4840-bbb1-bb894fc59d20\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "cursor": "pointer"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "PowerButton"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": ""
    }
  ]
}

 

formatcolumnsharepoint.png

View solution in original post

Hi, @Expiscornovus.

many thanks for your elaborate response!

 

Regarding the "active" - yes, I meant "trigger":) 

By the way. does a word "headers" mean "column headers" as shown in the screenshot below? If yes, would it mean that user name would have to written in the header?

mantastg08876_0-1605691296452.png

 




Super User II
Super User II

Hi @mantastg08876,

 

No, I mean the Response Headers from the trigger action in the Power Automate Flow. The flow is aware who triggered it.

 

You can extract that information from one of the properties of the Response Header, in this example either x-ms-user-name or x-ms-user-email.

 

triggerhttpresponseheaders.png

View solution in original post

Responsive Resident
Responsive Resident

@Expiscornovus , thank you!

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (89,211)