Answered by:
Retrieve entitiy logical name using the record guid

Question
-
Hi All,
I have got a requirement that, from the UI(third party tool) i will get only the guid of the record as the output using that guid i have to find the entity logic name from the backend and apply the logic and process further.
Can anyone suggest that how to get the entity logical name using only the the record GUID from CRM?
Regards,
Rekha J
Friday, February 3, 2017 7:37 AM
Answers
-
There is only way you have to use Trial and Error method. You need to execute RetrieveRequest for each entity which will result into error but one. The one without error is the answer for you. But it'll take a lot of time.
Fortunately we have ExecuteMultipleRequest, so follow the below pseudocode and you can definitely achieve a this with minimal performance.
- Get the metadata of all entities, essentially we need entity logical names.
- Generate Retrieve requests for all of the entities and add them to a list.
- Generate a ExecuteMultiple request and add all of the retrieve requests which you've generated in the previous step. Note that there are limits available in online CRM, so handle it.
- The Execute multiple is a single call, so you are about to save the number of calls i.e.' you will be making only one call to CRM.
- In the execute multiple response, all of the retrieve request would have been faulted except one which is the answer here.
- Still searching is cost effective, so use appropriate search algorithm to find the answer in minimum number of loops/steps.
Reply me if you've doubts.
- Marked as answer by Rekha JK Friday, February 3, 2017 1:24 PM
Friday, February 3, 2017 1:04 PM
All replies
-
you can use this method
http://www.crmanswers.net/2013/04/retrieve-entity-logical-name-from.html
My blog: www.crmanswers.net - CRM Theme Generator
- Proposed as answer by Guido PreiteMVP Friday, February 3, 2017 8:54 AM
Friday, February 3, 2017 8:54 AM -
Hi Guido,
Thanks for your reply.
We had thought about this logic first, but it leads to performance issue since there are lot of entities.
Is there any other optimum solution ?
Regards,
Rekha J
Regards, Rekha J
Friday, February 3, 2017 12:10 PM -
There is only way you have to use Trial and Error method. You need to execute RetrieveRequest for each entity which will result into error but one. The one without error is the answer for you. But it'll take a lot of time.
Fortunately we have ExecuteMultipleRequest, so follow the below pseudocode and you can definitely achieve a this with minimal performance.
- Get the metadata of all entities, essentially we need entity logical names.
- Generate Retrieve requests for all of the entities and add them to a list.
- Generate a ExecuteMultiple request and add all of the retrieve requests which you've generated in the previous step. Note that there are limits available in online CRM, so handle it.
- The Execute multiple is a single call, so you are about to save the number of calls i.e.' you will be making only one call to CRM.
- In the execute multiple response, all of the retrieve request would have been faulted except one which is the answer here.
- Still searching is cost effective, so use appropriate search algorithm to find the answer in minimum number of loops/steps.
Reply me if you've doubts.
- Marked as answer by Rekha JK Friday, February 3, 2017 1:24 PM
Friday, February 3, 2017 1:04 PM -
Simple way is to use foreach loop. This will loop over all the entities in the entity metadata, retrieves the entity logical name using OrganizationServiceProxy.Retrieve(<each entities logical name>,guid, <columnset>). If there is no exception in the above, the guid's entity logical name can be retrieved.
- Proposed as answer by Sree Bindu Saturday, February 4, 2017 5:14 AM
Saturday, February 4, 2017 5:12 AM