Data Operation while working with Microsoft Flow in Dynamics 365.
Hello Guys,
Today we will see some data operation while working with Microsoft Flow. But before If you are new to MS Flow then please read my this blog.
Do follow us to know more about Dynamics and Power Platform. Also if you like our blog then please comment and share this blog with your friends.
As of now we have created so many flows and used some data operation like Compose, Filter Array etc. Today we will see Parse JSON and Select data operation. Also we will see how can we avoid loops for making our flow faster in performance.
We will be creating one flow which will retrieve records of Three entities named Customer, Vendor and Partner. For time being I have already made these three entities in CRM and also created sample data. Here we go...
Navigate to https://us.flow.microsoft.com and click on Create. Select Instant Flow and configure it as below and click on Create.
Click on New Step. Search List records and configure it as below. Will do it for all three entities.
Now we will add next step i.e. Initialize Array variable. Configure it as below.
We will merge all these three entities data into one array variable. We have already retrieved records for all three entities. Now we can use Apply for each loop to add records of entity to the array. But we have to do it thrice as we have three entities. Also using loop is causing performance issue while working with large dataset.
To increase performance of the flow we will use Parse JSON data operation and also Select Data Operation. Once data will be selected, we will create string variable which will combined these three Select Data. Add new step and search Parse JSON. Configure it as below.
Now we have parsed all these three entities. Now click on add new step and search initialize variable and configure it as below.
Click on New step and search Select Data operation. Configure it as below.
Will do it for all parsed JSON.
Now we will append this select data to string variable. Add new step and search append to string. Configure it as below.
replace(replace(string(body('Select_Customer')),'[',','),']','')
replace(replace(string(body('Select_Vendor')),'[',','),']','')
replace(replace(string(body('Select_Partner')),'[',','),']','')
So now our string is ready. it contains records for all three entitles. Now will be adding this string to our array using JSON function. Add new step. Search Set variables.
json(concat(concat('[',substring(variables('Data String'),1,sub(length(variables('Data String')),1))),']'))
So our flow is ready now. Will run and check whether it is containing all records together in one array or not.
As you can see we have output which is as below.
[
{
"ID": "6872820e-6b10-eb11-a813-000d3a5306e5",
"Name": "Malishka Gupta",
"City": "New Delhi",
"Account Type": "Customer"
},
{
"ID": "5c5d2c19-6b10-eb11-a813-000d3a5306e5",
"Name": "Vihan Ranjan",
"City": "Lucknow",
"Account Type": "Customer"
},
{
"ID": "810bd228-6b10-eb11-a813-000d3a5306e5",
"Name": "Vinita Gupta",
"City": "Valsad",
"Account Type": "Customer"
},
{
"ID": "74dca636-6b10-eb11-a813-000d3a5306e5",
"Name": "Prashant Chavan",
"City": "Pune",
"Account Type": "Customer"
},
{
"ID": "fa60923d-6b10-eb11-a813-000d3a5306e5",
"Name": "Satish Gupta",
"City": "Ahemdabad",
"Account Type": "Customer"
},
{
"ID": "c35c0a50-6b10-eb11-a813-000d3a5306e5",
"Name": "Gaurav Singh",
"City": "Mumbai",
"Account Type": "Vendor"
},
{
"ID": "6402d756-6b10-eb11-a813-000d3a5306e5",
"Name": "Angline Mary",
"City": "Chennai",
"Account Type": "Vendor"
},
{
"ID": "75e0b662-6b10-eb11-a813-000d3a5306e5",
"Name": "Sneha Kolin",
"City": "Hydrabad",
"Account Type": "Vendor"
},
{
"ID": "01f87083-6b10-eb11-a813-000d3a5306e5",
"Name": "Gurpreet Gill",
"City": "Pune",
"Account Type": "Vendor"
},
{
"ID": "63ec448f-6b10-eb11-a813-000d3a5306e5",
"Name": "Sowmya Rajsekhar",
"City": "Chennai",
"Account Type": "Vendor"
},
{
"ID": "2e491bbe-6b10-eb11-a813-000d3a5306e5",
"Name": "Riya Gupta",
"City": "Varanasi",
"Account Type": "Partner"
},
{
"ID": "490f23cb-6b10-eb11-a813-000d3a5306e5",
"Name": "Sameer Chatale",
"City": "Chandrapur",
"Account Type": "Partner"
},
{
"ID": "ab5e07d2-6b10-eb11-a813-000d3a5306e5",
"Name": "Nilesh Karle",
"City": "Pune",
"Account Type": "Partner"
},
{
"ID": "9094b1d9-6b10-eb11-a813-000d3a5306e5",
"Name": "Amol Birar",
"City": "Nasik",
"Account Type": "Partner"
},
{
"ID": "b01288e5-6b10-eb11-a813-000d3a5306e5",
"Name": "Vighnesha Gupta",
"City": "Valsad",
"Account Type": "Partner"
}
]
Now we will retrieve only name and will store it in another array variable. Add new step and initialize array variable as below.
Add new step of select and configure it as below. We will select name from the All account array.
item()['Name']
Now add new step i.e. set variable and configure it as below.
Run the flow again.
As you can see we have Names in array variable as output.
Hope it helps...
Comments
Post a Comment