0
votes

I want to get all the fields of Account entity of CRM in console application and i am using Organization service of CRM.

I have written below code to retrieve fields from entity.

Entity account = _serviceProxy.Retrieve("account", new Guid("88035df8-8e6b-e511-80bd-000d3aa0bb1b"), new ColumnSet(true));
int i = 0;
foreach (KeyValuePair<string, object> objAttribute in account.Attributes)
{
  i++;
  Console.Write(i + ". " + objAttribute.Key + " " + objAttribute.Value + " \n");
}

But it is retrieving only 65 fields of entity, but when i checked in the entity fields from Customization, it actually has 259 fields.

So how do i retrieve all the entity fields from CRM 2013 on premise.

Is there anything related to security?

Can anyone please help me on this?

1
Cast it as an account and the account object will have all of the Account attributes (anything not listed in the current "Entity.Attributes" will be listed as null). It will not get around the field security issue mentioned by Guido. (It's possible that if you re-cast it back as an Entity, the attributes may include null values - I haven't tried this, so I'm not sure, but worth a shot).Joseph Duty

1 Answers

0
votes

You don't get all the attributes because:

  • The fields are empty so they are not inside the Attributes collection

OR

  • the user that is executing the Retrieve doesn't have a Read permission on fields protected with Field Level Security