Counting Sheeps

Scott DurowDyn365CE7 years ago14 Views

One of the strangest part of the Dynamics CRM WebApi is the pluralisation of the entity names.

In the old OData endpoint, the entity set name was <EntityLogicalName>Set – however in the OData 4.0 endpoing, the Logical Name is pluralised by using a simplistic set of rules which often results in the incorrect plural name being picked.

This introduced a conundrum – Performance vs. correctness. Do we query the metadata for the Entity Set name at runtime – or use a duplicate set of over simplified rules in our JavaScript?

The New Version 9 Client Side API

The good news is that with version 9, the Xrm Api now supports:


Xrm.Utility.getEntitySetName("contact")

This will return “contacts” and so we can safely use this without worrying if the plural name is correct or not or indeed if it changes in the future.

UPDATE: As it turns out – this method isn’t actually documented and so we have to use the getEntityMetadata function to be fully supported – see https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility/getentitymetadata

You can use it as follows:

Xrm.Utility.getEntityMetadata("lead",["EntitySetName"])
.then(function(m){
console.log(m.EntitySetName);
})

 

Hope this helps!

 

 

Original Post https://develop1.net/public/post/2017/10/16/Counting-Sheeps

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...