In a CDS (Current Environment), you have to option to Run the Flow under a context of a certain user. And there are a few options from which you can select from – Process Owner, Record Owner & Triggering User
Here’s my Flow in which the trigger is the CDS (Current Environment) connector. Show advanced options and you’ll see that there’s a field call as Run As
Which has the following 3 Options as I mentioned above –
Let’s look at each one of these.
To demonstrate Run As, my Flow is triggering on the Update of the Account record, an attribute in the CDS (Current Environment) connector called as RunAsSystemUserId provides the GUID of the System User used in the connector’s Run As field.
You can use triggerOutputs() function to get this GUID from the Trigger Outputs and use it to fetch the System User record. To see how triggerOutputs/triggerBody() works, check this post – Using triggerBody() / triggerOutput() to read CDS trigger metadata attributes in a Flow | Power Automate
As suggested, Flow Owner meaning the one who Owns the Flow
- If I select as Process Owner, no matter who triggers the Flow or who is the Owner of the record, the Run As user will be the one who Owns the Flow.
The record could belong to one owner and the other owner might modify it as shown below –
But the Flow will Run As the Owner of the Flow as suggested.
In my test, I believe the one who created the Flow becomes the first Owner and hence, is what it appears in Run As
- Easily, the record Owner in Dynamics 365 is the Owner of the record, so no matter who triggered the Flow or who the Flow owner is, the Record Owner will be the Run As user.
- In this example, Priyesh Wagh is modifying the record Owner by Kuldeep Gupta, the Flow Run As will show as Kuldeep Gupta
Triggering User [Also Default]
- If the Run As is set to Triggering User, whoever caused the Flow to Run is the Run As context user.
Let’s say Kuldeep Gupta is a user is modifying a record Owned by SYSTEM, the Run As user is Kuldeep Gupta.
- Now, if there’s no Run As selected or even if there are multiple Owners to the same Flow, the one who causes the Flow to run, is the context user of the Flow.
Let’s say Priyesh Wagh modified this record owned by SYSTEM, the Flow will Run As Priyesh Wagh
Hope this helps!!
Here are some more Power Automate related posts you might want to look at –
- Task Completion reminder using Flow Bot in Microsoft Teams | Power Automate
- Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
- Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
- Accept HTTP Requests in a Flow and send Response back | Power Automate
- Terminate a Flow with Failed/Cancelled status | Power Automate
- ChildFlowUnsupportedForInvokerConnections error while using Child Flows [SOLVED] | Power Automate
- BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
- Pause a Flow using Delay and Delay Until | Power Automate
- Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
- Setting Retry Policy for an HTTP request in a Flow | Power Automate
- Text Functions in a Flow | Power Automate
- Using Parse JSON to read individual List Records in Flow|Power Automate
2 thoughts on “Run As context in CDS (Current Environment) Flow Trigger | Power Automate”
Are you sure the “Process Owner” option uses the Flow Owner and not the user account used on the connection? I tried a sample Flow using Run-As “Process Owner”. Owner was “A” and Connection User was “B”. When I ran the Flow the RunAsSystemUserId was not that of the Flow Owner but the Connection User. Can you confirm please?
I tried using 2 users and kept them different. I didn’t pay attention to Connection User (I assume you mean CDS connection user).
Not sure if CDS connection user would supersede the Flow Owner. Maybe I’ll try to give it another shot.