Hi
I have some JavaScript which has code such as:
LookupFieldObject = Xrm.Page.data.entity.attributes.get('ser_accountid'); if (LookupFieldObject.getValue() !== null) { EntityId = LookupFieldObject.getValue()[0].id; EntityName = LookupFieldObject.getValue()[0].entityType; result = RetrieveEntityById(EntityName,EntityId, 'ser_ResellerId'); //note case sensitive
Then within RetrieveEntityById we use the REST endpoint and XrmsvcToolkit:
//correct for brackets around guid if (prmEntityIdValue.charAt(0) == "{") { prmEntityIdValue = prmEntityIdValue.substring(1, 37); }prmEntityName=prmEntityName.charAt(0).toUpperCase()+prmEntityName.substring(1); var res = null; XrmSvcToolkit.retrieve( { entityName : prmEntityName, id : prmEntityIdValue, async : false, select : prmEntityColumns, successCallback : function (result)
We use this in cases where the Id sometimes has brackets and sometimes not - this seems to matter. However the main point is that we need typically to change the name of the entity retrieved in EntityName to capitalise the first letter. So that EntityName has say 'account' and we need to change to Account so that the Rets query is against AccountSet - it is case sensitive. This is typically the case, but I have found for a custom entity (ser_salesorder) this is not the case - so the above code fails.
I could of course put the name of the account set as a parameter but this is a pity. Also in some code we might have several possibilities. Why this inconsistency and come to that why is REST case sensitive? BTW this is Rollup 12 Premise on a test deployment to prepare for upgrading our system to Rollup 12.
Of course I could use SOAP but for this sort of thing REST so much easier and perhaps faster.
Am I missing something obvious here? BTW I should say I really like XrmsvcToolkit - compact and nice to use.
Thanks
Paul