Skip to main content

Notifications

Power Automate Fundamentals # 47: List Rows Based on Expand Query in Power Automate

Power Automate Fundamentals # 47: List Rows Based on Expand Query in Power Automate

 

Introduction:

In order to get details of related entity for the selected entity without separate retrieve call we can leverage Expand Query .As a business scenario for the same vaccination use case extracting details of accounts that are present in list of contacts who took vaccination.       

 

Step 1:

Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and click on Flows on the left-hand side as shown in the below figure.

codevenkat_0-1646043781243.png

 

 

Step 2:

After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.

codevenkat_1-1646043798490.png

 

 

Step 3:

After Step 2, name the flow as List Rows - Expand Query take another step  and take initialize variable and name it as Initialize variable - Set ConsolidatedDetails Array  and provide inputs like below

 

Name : ConsolidatedDetails

Type : Array

Value :

 

as shown in the below figure.

codevenkat_2-1646043807937.png

 

Step 4:

After Step 3, select new action and under Data verse Connector and select action List Rows and name it as List rows – Contacts on the contact entity and provide the following inputs as below

 

Table name : Contacts

Select columns : fullname,telephone1,contactid,_parentcustomerid_value

Filter rows : (cr5bc_vaccinationcompleted eq true) and (parentcustomerid_account/accountid ne null)

Expand Query : parentcustomerid_account($select=address1_city,address1_composite,websiteurl,name)

 

 

as shown in the below figure.

codevenkat_3-1646043817625.png

 

Step 5:

After Step 4, Take Apply to Each Action and provide value as

 

outputs('List_rows_-_Contacts')?['body/value']

And take Set Variable name it as Append to array variable and provide the following values as

Name : ConsolidatedValues [ Select Initialize Array variable from Drowdown]

Value :

{

 "Customer Name": items('Apply_to_each')?['fullname'],

 "WebSiteUrl": items('Apply_to_each')?['parentcustomerid_account/websiteurl'],

 "TelePhone": items('Apply_to_each')?['telephone1'],

 "AccountName": items('Apply_to_each')?['parentcustomerid_account/name'],

 "Account City": items('Apply_to_each')?['parentcustomerid_account/address1_city']

}

 

 

as shown in the below figure.

codevenkat_4-1646043830337.png

 

Step 6:

After Step 5, save, test, and run the flow and observe the details as shown in the below figure.

 

 

codevenkat_5-1646043836027.png

 

Note:

  1. One can easily form expand query by the use of XRM Tool Box ,Fetchxml Builder and form fetchxml with link-entity and then click on View -> Power Automate Parameters -> Power Automate List Records Parameters popup and under Expand Query click on the content link where query is there so that you can copy the query and go to Step 4 and provide Expand Query as shown in the below figure.

codevenkat_6-1646043915362.png

 

 

  1. Make sure to save and run flow.
  2. Microsoft Documentation Details about expand query  can be found here .

 

 

Conclusion: In this way one can easily extract  details  of related entities linked to the base entity using expand query.

Comments

*This post is locked for comments

  • JustRhonda Profile Picture JustRhonda 215
    Posted at
    Power Automate Fundamentals # 47: List Rows Based on Expand Query in Power Automate

    I tried to follow this using the objects I need - Knowledgearticle & Knowledge_annotations but I get a failure for the Variable - 

    rg0173_0-1711543333042.png

     

    My Expand query is this: 

    rg0173_1-1711543376195.png

    Expand query knowledgearticle_Annotations($select=_objectid_value,notetext,annotationid,createdby,createdon,subject,versionnumber)

     

    What am I doing wrong? 

    rg0173_3-1711543577566.png

     

     

  • JustRhonda Profile Picture JustRhonda 215
    Posted at
    Power Automate Fundamentals # 47: List Rows Based on Expand Query in Power Automate

    How did you know to use "parentcustomerid_account"? I'm trying to follow along using the Task entity where I want to get the email of the Task Creator and the 'Regarding' field which in my case is a Knowledge Article. @codevenkat