Logic App Expand on multiple entities in Dynamics 365

Posted on Posted in Azure, Dynamics 365, Logic Apps, MS Dynamics, MS Dynamics CRM

As we know we can only get one entity back if we are using  Get record connector to query Dynamics 365 in Logic App however if we use List records to get a number of records or filter it on the basis of ID we have an option to get records from multiple entities as long as related entity is linked to main record i.e. Look up entity 

In this example we are going to query Work Order entity and filter it on the basis of a status (you can use any filter attribute you need to)

Next thing we need to do is click on Add new parameter and select ‘Expand Query’

We can add attribute name (relationship name) of related entity on our main entity and then can specify parameters names from related entity by adding $select, example below

We can call that selected attribute any where in steps below by using statement below (code view)

@{items(‘For_each’)[‘new_relationship][‘new_name’]}
This will display new_name attribute value from related antity
Similarly you can add multiple entities by adding comma (,) between each in Expand Query box.