Everybody who has worked with the Web Api, in the system formerly known as Dynamics CRM (honestly, I do not know how to call it now), must have notice that you can’t pass the EntityLogicalName to it. It expects the EntitySetName, which is a kind of plural name for the entity.
Not to be confused with the plural display name you can configure in the entity.
So far I had a little Javascript function that tried to imitade the rules wich are responsible for the generation of the EntitySetName. But since there can be some exceptions, I’m now the opinion that it would be more reliable to query the metadata directly from the system.
function getEntitSetName(strEntityLogicalName) { var req = new XMLHttpRequest(); req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/" + "EntityDefinitions(LogicalName='" + strEntityLogicalName + "')?$select=EntitySetName", false); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 200) { var result = JSON.parse(this.response); return result.EntitySetName; } else { return null; } } }; req.send(); }
[…] Artikel Get EntitySetName from Metadata von Ben ist auf leicht bewölkt veröffentlicht […]
[…] EntitySetName of the target record. I wrote here how you can get the EntitySetName from the Metadata with an webrequest […]
[…] EntitySetName of the target record. I wrote here how you can get the EntitySetName from the Metadata with an webrequest […]
[…] and activities in Javascript. I had a look into the SDK and remembered my previous post “Get EntitySetName from Metadata“. A little modification and I get true or false from the ‘isActivity’ information […]
[…] and activities in Javascript. I had a look into the SDK and remembered my previous post “Get EntitySetName from Metadata“. A little modification and I get true or false from the ‘isActivity’ information […]
[…] and activities in Javascript. I had a look into the SDK and remembered my previous post “Get EntitySetName from Metadata“. A little modification and I get true or false from the ‘isActivity’ information […]