Hi Will,
The assign message means that only change the owner field and only have something like Target and Assignee in the Input Parameter, so I don't think that line after this code will be executed:
if (ContainingTargetFields)
Because if you see:
bool ContainingTargetFields = !_entity.Attributes.Contains("asc_statutlocalite") && !_entity.Attributes.Contains("asc_typederoute");
I don't think that the entity contains this "asc_statutlocalite" field..
Because you don't update any field on it.
So, I will suggest you to retrieve the Account record first then get the field.
And in the first if,
I am not sure that this: if (_entity.LogicalName == "account") will work.
I suggest you to use this method:
// Verify the message context
if (context.InputParameters.Properties.Contains("Target") ||
context.InputParameters.Properties["Target"] is Moniker == false ||
context.PrimaryEntityName != entityName)
{
return;
}
//continue your logic here
See this:
danielcai.blogspot.com/.../use-crm-assign-message.html
So, you need to get the current Account Id using this:
Moniker moniker = (Moniker)context.InputParameters.Properties["Target"];
Guid accountid = moniker.Id;
Then after that you can use to retrieve the Account using service.Retrieve() function like usual.
After that, you will get the entity.
So you need to do something like:
*Was
Entity _entity = (Entity)context.InputParameters["Target"];
*Change to
Entity _entity = service.Retrieve("account", accountid, new ColumnSet(true));
Then you can continue to retrieve the fields, your option set checking.
But remember to change your if using the link method.
Then just continue.
Sorry for typo error, I am not using any compiler editor.
Hope this helps.
Thanks.