Answered by:
How to get Name/FullName/Title field attribute dynamically -CRM 2011

Question
-
Hi,
I want to get the name attribute value For all entities in CRM. So I am creating a dynamics fetch expression query to retrieve the entity-related records. But In CRM 2011 this attribute name is not common.
For example
1. Account has 'Name'
2. Contact has 'fullname'
3 incident has 'title' etc.
string fetch1 = @"
<fetch mapping='logical'>
<entity name='account'>
<attribute name='name'/>
<filter type='and'>
<condition attribute='accountid' operator='eq' value='[GUID]' />
</filter>
</entity>
</fetch> ";fetch1 = fetch1.Replace("[GUID]", ContactId); fetch1 = fetch1.Replace("account", entityname);
Can you please help me to make appropriate attribute name based on the entity.
Thanks in advance.
-Prem
Wednesday, January 2, 2013 10:11 AM
Answers
-
Hi Prem,
you could use RetrieveAllEntitiesRequest to fetch entity details and get it's primary field and then you can use the primary field name in your fetchxml.
HTH
Contact Me
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by John Grace - North52 Thursday, January 3, 2013 1:33 PM
- Marked as answer by prem192 Tuesday, January 8, 2013 10:32 AM
Wednesday, January 2, 2013 10:43 AMModerator
All replies
-
Hi Prem,
you could use RetrieveAllEntitiesRequest to fetch entity details and get it's primary field and then you can use the primary field name in your fetchxml.
HTH
Contact Me
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by John Grace - North52 Thursday, January 3, 2013 1:33 PM
- Marked as answer by prem192 Tuesday, January 8, 2013 10:32 AM
Wednesday, January 2, 2013 10:43 AMModerator -
Thanks...
That resolved my problem
-
Prem
Tuesday, January 8, 2013 10:32 AM -
Hi Prem,
Is is so simple now in crm 2013 .
You can visit this link for it
http://crmjavascripts.blogspot.in/2014/04/new-java-script-functions-in-crm-2013.html
jsh
Thursday, April 17, 2014 7:19 AM