Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve entity names in CRM 2016

In our solution, we are building HTTP/ODATA requests dynamically.

For example, we will build a URL that looks like this:

[http://org....api/v8.1/]accounts(00000000-0000-0000-0000-000000000001)/primarycontactid?$select=fullname

How do we dynamically get a list of all the entities such as 'accounts'?

In 2011, we would simply execute against LeadSet/AccountSet/etcSet, what is the strategy in 2016?

like image 761
Alex Gordon Avatar asked Oct 22 '25 01:10

Alex Gordon


1 Answers

I don't know if there is some "language" trick (obviously the name of the set is just plural name in english of the entity, but that's not good enough for me), so I it like that - simply call webAPI metadata:

http://[crmurl]/api/data/v8.2/EntityDefinitions?$select=EntitySetName,LogicalName&$filter=LogicalName eq 'account'

result is the following:

{
  "@odata.context":"http://[crmurl]/api/data/v8.2/$metadata#EntityDefinitions(EntitySetName,LogicalName)","value":[
    {
      "EntitySetName":"accounts","LogicalName":"account","MetadataId":"70816501-edb9-4740-a16c-6a5efbc05d84"
    }
  ]
}

So you get the idea. Of course you can simply skip the $filter part and simply get list of all set names and cache them somewhere.

like image 67
Pawel Gradecki Avatar answered Oct 24 '25 13:10

Pawel Gradecki