Home Power PlatformsPower Automate External portal display data from Dynamics 365 using Power Automate.

External portal display data from Dynamics 365 using Power Automate.

by Mo Faheem

Patryk Wojtal, Dynamics 365 Solution architect at CRM Dynamics, Built a Power Automate flow to inquire data from Dynamics 365 and present this data on an external website. I believe that this can be useful if a client wants to present data to public websites; therefore, I rebuilt the flow on a test environment.

Trigger using HTTP request

You can get data from Dynamics 365 using Request Connector. In the request body JSON Schema, add the followings text.
{
“type”: “object”,
“properties”: {
“industry”: {
“type”: “string”
}
}
}

HTTP request

Set the method to “Get”.

For our example, we will be inquiring all Dynamics 365 Accounts in a specific industry, hence, we add a relative path [industry/{industry}].

Set Variables

Condition Variable

Declare a variable “industry” of the typed string and set the value to the industry passed in the URL.

The variable will be used in the Fetch XML query’s condition.

Declare String variable industry

Incremental Variable

Declare a variable “Count” of the typed Integer and set the value to 0.

The variable will be used to count the number of return records and at the end, pass this value to the external enquirer.

Incremental Variable

List Dynamics 365 records

Using list records (current environment) connecter, we will list all Dynamics 365 accounts who belong to a specific industry.

From Dynamics 365 Advanced Find, generate the Fetch XML query.

In the Condition tag, replace the condition value with the condition attribute.

Dataverse list records

Loop the list record

Using the Apply to each, any action can be included in this step even update the Dynamics 365 records. For this example, we will increment the count variable by 1.

Apply to each

Function Return

Generally, I would return one value such as the count, but to give a more meaningful to my inquiry I added the following in the body of the return response,

Body: There are [Count] Accounts of the industry [industry]

Function Return

Testing the Power Automate

  1. Coping the HTTP Get URL from the trigger.
  2. Replacing the {industry} from the URL with one of the industry option set. I will try the value 1 & 2
Testing the Power Automate
test 1 industry 1
Test 1 – The industry equles 1
test 2 industry 2
Test 2 – The industry equles 2

The 1st test returned 13 accounts in the industry 1, and the 2nd test returened 3 accounts for industry 2.

The same concept is used to build an API, read more

Related Articles

Leave a Comment