CRM 2011 – Entities filter out null attributes

I was looking at the CRM 2011 entity today.  I was having to search the entity attributes to find a the value of a variable/field.

Initially when I did this the entity variable is ent

ent.GetAttributeValue(fieldname);

I was getting nothing

I then did a count on the number of attributes in the entity

ent.Attributes.Count

it returned 51 but the entity had 83 attributes.  Which meant I was missing 32 variables.

I found out that it only lists the attributes that don’t have a null value.  I worked this out because I went and gave one of the missing fields a value and then it appeared in the list of attributes.

This makes sense really because why bother including lots of variables which haven’t been set and don’t have a value but it can be quite confusing if you aren’t expecting it and have put some logic in based on the variable

 

Advertisement

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.