Trigger Power Automate (Flow) Synchronously from CDS

đź’ˇ Triggering the flow Synchronously may not be a good idea. So, use it carefully.

💡 The steps mentioned here are not purely “citizen developer”, having said that it also doesn’t involve any coding. One should have knowledge on how to use Plugin Registration tool though.

Again, as I mentioned in my previous blog post here, this may not be an every day requirement but certainly worth to know the possibilities. In my case, I have a special requirement where I can’t lose the initial few seconds of flow trigger via async pipe line (which also means a definite no-no to waiting stage for async pipe line to clear). That’s when this super cool tip of the day helped me, thought it would be useful to blog it in detail steps.

Step 1: Create your flow as a HTTP Trigger flow.

Simply return the response and save the flow so that we can configure the sync trigger.

After saving flow will generate a trigger URL (with key), which essentially is a webhook for us. Copy the URL.

đź’ˇ Ensure you are Saving the flow, or else you will not see the URL here.

This is how the sample URL looks like (use a URL Decoder to remove those %s)

https://xxxxxx.uksouth.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxx/triggers/manual/paths/invoke?api-version=2016-06-01&sp=/triggers/manual/run&sv=1.0&sig=0wBbRVw9j5P5VIN2SqtIrswjU9UUVhF_k00gwOgaCSY

Step 2: Open Plugin registration tool, Register new webhook (use Ctrl+W). Set the values as shown below and hit Save.

Name: Some meaningful name

Endpoint URL : The first part of the URL (excluding query string params)

Authentication: HttpQueryString

Add all other query string parameters one by one as shown..

Register a new step on the required entity, in my case – I have used Account entity, Create.

That’s it.. Create an account and you should be able to see the flow triggered at the same time..


This is where the post ideally should end as it is supposed to show case how to trigger the flow synchronously.. however, if you need a bit more help on how to read the information from the triggered data, check the below screenshots…

đź’ˇ In my experience, triggering the flow synchronously is not a big deal, but grabbing the required details from the entity is an annoying task.

đź’ˇ For easy reference, I have pasted the peek code values of the flow for each step.

 

{
"inputs": {
"from": "@triggerBody()?['InputParameters']",
"where": "@equals(item()?['key'], 'Target')"
}
}

 

{
"inputs": {
"from": "@first(body('FilterForTarget'))?['value/Attributes']",
"select": {
"AttributeName": "@item()?['key']",
"AttributeValue": "@item()?['value']"
}
}
}



{
"inputs": {
"from": "@body('AllAvailableAttributesInTarget')",
"where": "@equals(item()?['AttributeName'], 'name')"
}
}



{
"inputs": {
"host": {
"connectionName": "shared_teams_1",
"operationId": "PostUserNotification",
"apiId": "/providers/Microsoft.PowerApps/apis/shared_teams"
},
"parameters": {
"PostNotificationRequest/recipient/to": "xxx@xxx.xxx",
"PostNotificationRequest/messageBody": "Use this URL –

https://org6d53b314.crm11.
dynamics.com/main.aspx?appid=1cc3291b-30c6-ea11-a812-
000d3a7fcd1e&newWindow=true&pagetype=entityrecord
&etn=account&id=@{triggerBody()?['PrimaryEntityId']}",
"PostNotificationRequest/messageTitle": "New High value
customer added - @{first(body('GetNameAttribute'))?['AttributeValue']}"
},
"authentication": "@parameters('$authentication')"
}
}

The full flow

And the result –

Happy FLOWing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s