Execute Action with “EntityCollection” Parameter using Web API in Dynamics 365

By | December 20, 2016

Introduction

Recently, we had a requirement where we wanted to Execute Custom Action in Dynamics CRM by passing “EntityCollection” type parameter using Web API. We have discussed how to execute the action using Web API in one of our earlier blog. However, in this blog we just explained executing action with string parameter.

Here we are going to focus on executing action with “EntityCollection” parameter using Web API.

You can see below that we have created a Custom Action:

Dynamics CRM Web API

Below code snippet will help you to Execute Action using Web API:

Conclusion:

This blog will help you to execute action by passing “EntityCollection” parameter using Web API in Dynamics 365.

Now export Dynamics 365 reports to multiple formats in mere one click using Click2Export!

2 thoughts on “Execute Action with “EntityCollection” Parameter using Web API in Dynamics 365

  1. kamrananjum200786@gmail.com'kamrananjum

    HI Team,

    I want to pass entity reference on collection in each collection object. Can you help on this.
    For Eg: In above account object we have to pass contact also somewhere like
    {
    “@odata.type”: “Microsoft.Dynamics.CRM.account”,//entity type
    “accountid”: “C4CA0B66-59B9-E611-8106-C4346BDC0E01″,//Record’s guid
    “name”: “Test”,//name field of the account entity
    “accountnumber”: “123”//accountnumber field of the account entity
    contactid :/// this is reference field on account
    },
    So how to pass Entity reference in object. ??

    1. inogic Post author

      Hi Kamran,

      You can pass entityreference field in the entitycollection parameter like in the below example:

      “Accounts”://EntityCollection parameter
      [
      {
      "@odata.type": "Microsoft.Dynamics.CRM.account",//entity type
      "accountid": "9C1E6089-7739-E711-80EE-C4346BAC4304",//Record's guid
      "name": "Test",//name field of the account entity
      "accountnumber": "123",//accountnumber field of the account entity
      "primarycontactid": { "@odata.type": "Microsoft.Dynamics.CRM.contact", "contactid": "BC036ADB-F239-E711-80EE-C4346BAD526C" }
      },
      {
      "@odata.type": "Microsoft.Dynamics.CRM.account",
      "accountid": "9C1E6089-7739-E711-80EE-C4346BAC4304",
      "name": "Test2",
      "accountnumber": "1234",
      "primarycontactid": { "@odata.type": "Microsoft.Dynamics.CRM.contact", "contactid": "AC036ADB-F239-E711-80EE-C4346BAD526C" }
      }
      ]

      In the above example, we have set the “primarycontactid”(entityreference) field of Account entity.

      Hope this helps!

Leave a Reply