0
votes

I have Dynamics CRM 2011 plugin (retrieve, post-action) which should simply set the value of custom field when retrieving Contact entity:

    public void Execute(IServiceProvider serviceProvider)
    {            
        IPluginExecutionContext context = PluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));            
       if (context.OutputParameters != null)
       {
          Entity entity = (Entity)context.OutputParameters["BusinessEntity"];
          if (entity.Attributes.ContainsKey("new_markerexists") == false)
                return;
          entity["new_markerexists"] = "Marker exists.";

However, CRM plugin can not find this or any other custom field. It works fine with the standard fields.

What am I missing here?

Thanks!

2
what means "CRM plugin can not find this or any other custom field", do you mean that if you do entity["firstname"] = "TEST"; with firstname as standard field, your retrieve returns the updated value?Guido Preite

2 Answers

1
votes

As stated here: https://stackoverflow.com/a/9903306/1023562

In CRM, only properties that have been set or updated are included.

My custom fields did not have any value set, so CRM simply did not include them in entity.Attributes collection.

1
votes

If your custom field is empty then it will not add the field in the attribute collection. If you want to get the Custom field you will must have to provide some value to it. I have tested and it is working.