Get all attributes of the records in CRM

Many times there could a requirement where we need to get most of the attributes of a record in CRM. Then, we can write the code to get all attributes.
Here is the code for it.
We can achieve this by using two things
1) Fetch XML
  In FetchXML, if you forgot to mention attribute tag by default it will get all the attributes.

string strFetchXML = @”

EntityCollection entColAccounts = iService.RetrieveMultiple(new FetchExpression(strFetchXML));

strFetchXML = @”

 entColAccounts = iService.RetrieveMultiple(new FetchExpression(strFetchXML));
2) QueryExpression

QueryExpression objQueryExpression = new QueryExpression(“account”);

objQueryExpression.ColumnSet = new ColumnSet(true);
entColAccounts = iService.RetrieveMultiple(objQueryExpression);
Note: Mostly avoid retrieving the record with the all-attributes  as there could be lot of performance degrade. It is always best and recommended way to mention the specific attributes and retrieve records from CRM.
Hope this helps.

Happy CRM’ing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s