Run as option in When a row is added, modified or deleted trigger – Power Automate


Let us see Run As option of When a row is added, modified or deleted trigger in action, to understand its behavior.

Below is our example flow – it triggers when a field on the case is updated and then it updates the lead record.

Here we have not specified any value for Run as for When a row is added, modified or deleted trigger step.

On updating a case record using the User 1 account who is also the Flow Owner, we can see the modified user as User 1 for the lead record.

Let us trigger the flow this time through User 2.

This time also modified by for the lead record is User 1, even though the Modifying User and Row Owner were different.

So if Runs as is not specified, the Microsoft Dataverse actions are performed using the context of the Flow Owner.

To test it further let us remove the update rights of User 1, who is the flow owner, and trigger the flow again using User 2.

As expected the flow run fails this time.

Principal with id 7252e222-c07f-ec11-8d22-000d3a98d479 does not have WriteAccess right(s) for record with id 8ce6c6de-1bff-e411-80d4-c4346bac4730 of entity lead

Not let us specify Run as = Modifying User this time, and trigger the flow using User 2 again. (we have restored the rights of User 1)

This time also we can see the modified by the user as User 1 (Nishant Rana) the flow owner.

For it to run under the context of the user set as “Run As” in When a row is added, modified or deleted trigger, we need to select the Use invoker’s connection setting for the Update a row step.

Let us trigger the flow again through User 2, remember we have Run As set as modifying user.

Interestingly it still shows User 1 as the Modified By user.

Let us again remove the write rights of User 1 and trigger the flow using User 2.

This time flow is successful. If you remember it failed last time when we removed the User 1 rights and the Run as was default Flow Owner.

And this time, it shows modified by as User 2. (as we can see for user 1, the record is read-only as we have the rights removed)

This time it worked because had set Run As as Modifying User and specified Use invoker’s connection for the subsequent step i.e. update a row in this case, so it used User 2’s context which modified the case record to trigger the flow, which in turn updated the lead record using user 2’s context.

Now it will fail if User 1 updates the case record and triggers the flow because it will try to update the lead record using its context i.e. Run as = modified by

We will observe a similar behavior with Run As = Row Owner.

In case the owner of the record is a team, instead of a user, then it falls back to the flow owner option.

Get all the details here – https://docs.microsoft.com/en-us/power-automate/dataverse/create-update-delete-trigger#user-impersonation-using-run-as

Also check – https://d365demystified.com/2020/10/30/run-as-context-in-cds-current-environment-flow-trigger-power-automate/

Hope it helps..

Advertisements

Fixed – Flow client error returned with status code “Forbidden” and details – MissingAdequateQuotaPolicy, the user does not have a service plan adequate for the non-Standard connection in Power Automate


Recently one of the users reported this error while trying to Test a flow.

Request to XRM API failed with error: ‘Message: Flow client error returned with status code “Forbidden” and details “{“error”:{“code”:”MissingAdequateQuotaPolicy”,”message”:”The user ‘8a47d139-662e-4b73-bca3-53a59e8bebeb’ does not have a service plan adequate for the non-Standard connection ‘Microsoft Dataverse’. https://go.microsoft.com/fwlink/?linkid=2123710″,”extendedData”:{}}}”. Code: 0x80060467 InnerError: ‘.

As here the Premium Dataverse connection was being used, the resolution was to either purchase a Per User plan or Per Flow plan or to enable the trial of Power-Automate per user plan.

After the trial was enabled for the user, the error got resolved.

Hope it helps..

Advertisements

Understanding Change limits option in Do until control – Power Automate


Within Do Until control in Power Automate we have the option of defining the limits i.e. how long the do until will run either based on count or timeout.

By default, the value for count is 60 and Timeout is PT1H which equates to 1 hour i.e. it will either run 60 times or will run for 1 hour which occurs first.

Let us set the count to 5 and test it.

We have also added the delay of 1 minute along with the condition for do until and triggering it on the update of a lead record.

As expected if the condition is not true, after running 5 times it stops successfully.

Now let us change the Timeout to 2 minute and we keep the count as 5.

As expected after 2 minutes (by that time it has looped 2 times with 1 min delay), the flow stops successfully.

The flow will also be successful when the Do until condition is met.

Here we can make use of Current Iteration Index property of Do until to find out the number of times it has looped.

To set the time out format –

https://www.digi.com/resources/documentation/digidocs/90001437-13/reference/r_iso_8601_duration_format.htm

Lastly the Count value can be maximum 5000 – 

countlimit

Also check –

https://nishantrana.me/2022/05/17/fixed-invalid-template-unable-to-process-template-language-expressions-in-action-template-language-expression-cannot-be-evaluated-the-template-action-is-not-defined-in-the-current-scope/

https://nishantrana.me/2022/01/19/how-to-use-do-until-and-delay-in-power-automate/

https://nishantrana.me/2022/05/19/filter-rows-and-trigger-conditions-in-power-automate/

Hope it helps..

Advertisements

Terminate and Cancel Flow Run in Power Automate


Cancel Flow Run action which is part of the Power Automate Management connection be used to cancel a running flow along with Terminate.

Cancel Flow Run

We can specify the below expressions for its parameters as below.

Environment 

workflow().tags.environmentName

Flow 

workflow().name

Run ID 

workflow().run.name

The Cancel Flow Run can be used inside Do Until and Apply To Each control, unlike the Terminate.

If we try using Terminate inside Do Until we will get a similar error message as below.

Request to XRM API failed with error: ‘Message: Flow client error returned with status code “BadRequest” and details “{“error”:{“code”:”InvalidOpenApiFlow”,”message”:”Flow save failed with code ‘InvalidWorkflowRunAction’ and message ‘The workflow run action ‘Terminate’ has type ‘Terminate’ that is not allwed to be nested under an action of type ‘until’.’.”}}”. Code: 0x80060467 InnerError: ‘.

If we have implemented the Try, Catch and Finally block (scope), the Catch and Finally steps will be skipped as shown, on canceling the flow.

Interestingly the steps next to Cancel Flow Run still run.

The status will show up as canceled for the flow in the flow history.

Now let us see what happens in the case of Terminate action.

In the case of setting the Terminate Status as Failed – we see the next step skipped along with Catch and Finally.

Let us see in the case of Status = Cancelled

The status will be Canceled.

In the case of Status = Succeeded,

Here the status will be Succeeded.

Do check –

https://sharepains.com/2018/09/11/microsoft-flow-never-terminate-your-flows-unless-you-like-failure/

Hope it helps..

Advertisements

Fixed – Unable to process template language expressions for trigger. In the template language function ‘convertToUtc’, the value provided for the time zone id ‘Gulf Standard Time’ was not valid while using Delay Until property– Power Automate


Recently while using Delay until property of the trigger, in one of the flows, we got the below error

“Unable to process template language expressions for trigger ‘When_a_row_is_added,_modified_or_deleted’ at line ‘1’ and column ‘16344’: ‘In the template language function ‘convertToUtc’, the value provided for the time zone id ‘Gulf Standard Time’ was not valid. ‘.”

Usage of Delay until is nicely explained here by Debajit –

https://debajmecrm.com/how-to-delay-a-power-automate-flow-execution-till-a-specified-date-and-time/

https://debajmecrm.com/replicate-dynamics-365-workflow-timeout-wait-condition-in-microsoft-flows/

 

Delay until = convertToUtc(‘2022-05-16T17:22:00′,’Gulf Standard Time’)

It turns out that Gulf Standard Time is not a valid time zone id.

Changing it to Arabian Standard Time resolved the issue for us.

i.e.

convertToUtc(‘2022-05-16T19:22:00′,’Arabian Standard Time’)


Also check – https://nishantrana.me/2022/01/19/how-to-use-do-until-and-delay-in-power-automate/

Hope it helps..

Advertisements

Fixed – Authorization failed. The client with object id does not have authorization to perform action ‘Microsoft.Authorization/roleAssignments/write’ over scope ‘/subcriptions’ while configuring Azure Synapse Link for Dataverse


Recently while configuring Azure Synapse Link for Dataverse, for exporting data to Azure Data Lake we got the below error –

{“code”:”AuthorizationFailed”,”message”:”The client ‘abc’ with object id ‘d56d5fbb-0d46-4814-afaa-e429e5f252c8’ does not have authorization to perform action ‘Microsoft.Authorization/roleAssignments/write’ over scope ‘/subscriptions/30ed4d5c-4377-4df1-a341-8f801a7943ad/resourceGroups/RG/providers/Microsoft.Storage/storageAccounts/saazuredatalakecrm/providers/Microsoft.Authorization/roleAssignments/2eb81813-3b38-4b2e-bc14-f649263b5fcf’ or the scope is invalid. If access was recently granted, please refresh your credentials.”}


As well as the below error –


As the error suggests the error was because the user account used was not having the appropriate role(s) assigned.

The user needs to have the Owner as well as Blob Storage Data Contributor role on the Azure Data Lake Storage Gen2 account.

Also check –

https://nishantrana.me/2020/09/07/error-access-to-the-resource-is-forbidden-while-trying-to-connect-to-azure-data-lake-storage-gen2-using-power-bi-desktop/

https://nishantrana.me/2021/06/24/fixed-authorizationfailed-the-client-with-object-id-does-not-have-authorization-to-perform-action-microsoft-authorization-roleassignments-write-over-scope-storageaccou/

https://docs.microsoft.com/en-us/power-apps/maker/data-platform/azure-synapse-link-synapse#prerequisites

Hope it helps..

Advertisements
%d bloggers like this: