Logic Apps – List Dynamics CRM Records

Logic Apps – List Dynamics CRM Records

With the managed “Dynamics CRM” API, Microsoft provides a way to integrate your Dynamics CRM Online platform with Azure Logic Apps. The connector can be used as a trigger (On Create or On Update) as well as an action (Create a new action or List Records).

In this post, we will show how to use the connector as a trigger event for a Logic App. We will use the output of the trigger event to use the “Dynamics CRM Online – List Records”-action. This action allows you to request a list of records for a specific CRM Entity.

Creating the Logic App

Go to http://portal.azure.com and login to your Azure Account.

In the left hand corner, click “New”, type “Logic App” in the search box and select “Logic App” from the result list.

On the Logic App Detail slice, click “Create”.

Provide the Name, Subscription, resource group and Location details when prompted in the “Create Logic App”-slice. A “Resource Group” is a container which you can use to logically group your created Azure components & applications. Complete by clicking the “Create”-button.

Once creation of your new Logic App completed, select it from your Resource Group. Azure already provides a couple of templates which you can use as a building block for your Logic App. For this scenario, we will start with a Blank LogicApp.

Trigger Event – When a product is created

Select the “Dynamics CRM Online – When a record is created” from the Managed API-list.

If you haven’t logged in to your CRM Online Portal before, you will be prompted to login.

Select your “Organization Name” and choose the “Products”-Entity

The Logic App will be triggered when you created a new product in your Dynamics CRM Online Organization.

The output will be a JSON-string:

“body”: {“@odata.etag”: “”,

“ItemInternalId”: “b1ab7022-f747-e611-80e9-5065f38915a1”,

“iskit”: false,

“productid”: “b1ab7022-f747-e611-80e9-5065f38915a1”,

“createdon”: “07/12/2016 06:09:05”,

“productstructure”: 1,

“exchangerate”: 1,

“statecode”: 0,

“_defaultuomscheduleid_value”: “a27fee06-4108-49c5-b97f-888735bf1b66”,

“_defaultuomscheduleid_type”: “uomschedules”,

“_pricelevelid_value”: “07e71e25-f344-e611-815b-5065f38bf371”,

“_pricelevelid_type”: “pricelevels”,

“versionnumber”: 640977,

“producttypecode”: 1,

“modifiedon”: “07/12/2016 06:10:17”,

“description”: “Webshop Sample Product 3”,

“_defaultuomid_value”: “bde2512b-045b-4ae4-9133-2d9223bb9b0d”,

“_defaultuomid_type”: “uoms”,

“quantitydecimal”: 2,

“_transactioncurrencyid_value”: “21f0569e-9644-e611-80ea-5065f38bf341”,

“_transactioncurrencyid_type”: “transactioncurrencies”,

“isstockitem”: false,

“_createdby_value”: “d3fa79bc-9644-e611-80ea-5065f38bf341”,

“_createdby_type”: “systemusers”,

“_modifiedby_value”: “d3fa79bc-9644-e611-80ea-5065f38bf341”,

“_modifiedby_type”: “systemusers”,

“name”: “Webshop Sample Product 3 “,

“statuscode”: 1,

“_organizationid_value”: “e4905782-a75a-4c46-855b-135f1194ac80”,

“_organizationid_type”: “organizations”,

“productnumber”: “WBS000003”


Let’s say that we would like to know what the default price of this product is. Those who have some experience with Dynamics CRM will most likely know this can be retrieved through the “productpricelevel”-entity.

We will retrieve this information from CRM using the “List Records”-action

Action – Dynamics CRM Online – List Records

In the Logic App Designer, click “New Step”, followed by “Add an action”.

Select the “Dynamics CRM Online – List records” – API from the list.

Continue by choosing the “Organization Name” and selecting “Price List Items” from the “Entity Name”-dropdown. “Price List Items” is the display name in the Adapter for the “productpricelevel”-entity. Since we already logged in to Dynamics CRM during configuration of the trigger, we do not have to repeat this step here.

The connector uses ODATA-syntax for filtering and ordering. When defining the filter, you have the possibility to select properties from the output of the trigger event to build your filter expression. Here, we will perform a lookup in the “Price List Items”-entity where the property “_productid_value_” is equal to the ProductId which we received as an output in the Trigger Event (Outputs from When a record is created).

The output of this connector is again a JSON-string, with “amount” being the price we wanted to retrieve. The output is returned as an array of objects. When using the output of this action as input for a following action, Azure will decide for you to create a Foreach-container for this new action.

“body”: {“@odata.context”: “$metadata#datasets(‘org6245146b.crm4’)/tables(‘productpricelevels’)/items”,

“value”: [


“@odata.etag”: “”,

“ItemInternalId”: “5cbd0187-1d48-e611-80e9-5065f38915a1”,

“_transactioncurrencyid_value”: “21f0569e-9644-e611-80ea-5065f38bf341”,

“_transactioncurrencyid_type”: “transactioncurrencies”,

“_uomid_value”: “c725e7a6-f747-e611-80e9-5065f38915a1”,

“_uomid_type”: “uoms”,

“_pricelevelid_value”: “07e71e25-f344-e611-815b-5065f38bf371”,

“_pricelevelid_type”: “pricelevels”,

“quantitysellingcode”: 1,

“productpricelevelid”: “5cbd0187-1d48-e611-80e9-5065f38915a1”,

“versionnumber”: 641256,

“_modifiedby_value”: “d3fa79bc-9644-e611-80ea-5065f38bf341”,

“_modifiedby_type”: “systemusers”,

“_createdby_value”: “d3fa79bc-9644-e611-80ea-5065f38bf341”,

“_createdby_type”: “systemusers”,

“_uomscheduleid_value”: “a27fee06-4108-49c5-b97f-888735bf1b66”,

“_uomscheduleid_type”: “uomschedules”,

“pricingmethodcode”: 1,

“_productid_value”: “2ec0c873-1d48-e611-80e9-5065f38915a1”,

“_productid_type”: “products”,

“modifiedon”: “07/12/2016 10:44:00”,

“exchangerate”: 1,

“createdon”: “07/12/2016 10:44:00”,

“amount_base”: 166,

“amount”: 166





To help you build query expressions, you need to know the actual property names. The designer does not provide a way to select those. In order to help me, I downloaded the OData Metadata-file from Dynamics CRM.

In dynamics CRM, go to Settings à Customizations

Select “Developer Resources”

Here you can download the metadata-file.

The file will list all the available entities, their properties, navigation properties, as well as available actions for the CRM REST API on which the connector is built on top of.