A retrieve request to CrmService or the pre/post image does not seem to contain all the entity attributes.

You are developing a plug in for Microsoft CRM 4.0.

Long story short, the IPluginExecutionContext instance passed to the plugin code has an InputParameters property who might contain a “Target” property. This property may be your entity so most common code examples will try to cast it to a DynamicEntity.

DynamicEntity entity = context.InputParameters.Properties["Target"] as DynamicEntity;

If you end up with a non null value you are probably in possession of your entity.

By default the code that you write in the plugin will have access under the DynamicEntity.Properties collection to only attributes of the entity that just got created or updated or deleted.

To access all the attributes, even the one that did not change you can either spawn an instance of the CrmWebService calling contect.CreateCrmWebService or register for a pre/post image.

Now, let us get to the problem that I encountered. Inspecting the entity.Properties items I noticed that they are less, … way less than the total number of attributed the entity/table has.
It took me a while until I realized that the DynamicEntity.Properties collection will not contain attributes that have null (or Nothing) values even when you implicitly requested the entity.

This is something I read in a book so while I was trying to understand what is happening the answer was actually lurking in the recesses of my brain. When I inspected the database record of the entity I just created it struck me.

Hopefuly this will save you some time if you get here first. 😀