I'm working on a CRM 2011 plugin that changes one field's value on an account entity if user deactivates the account. I spent a lot of time wondering what's wrong because I received the following error every time I deactivated some account
"Error. An error has occured. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support"
But after some time I noticed that even if the error my plugin actually works perfectly. My code is below just in case (notice that we call our accounts as clients)
Entity client = (Entity)context.InputParameters["Target"];
OptionSetValue state = (OptionSetValue)client["statecode"];
if (state.Value == 1)
{
OptionSetValue clientStatus = new OptionSetValue(100000000);
client["customertypecode"] = clientStatus;
service.Update(client);
}
So does anyone has any thoughts what could cause this problem? If I disable my plugin and then deactivate any account it works perfectly without any errors.
My plugin is registered at Pre-operation stage synchronously.
Thank you in advance!