I've written a plugin with the following configuration:
I'm simply trying to set one datetime
field to equal another datetime
field:
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];
try
{
if (entity.LogicalName == "list" && entity.Attributes["gbs_lastusedonoriginal"] != null)
{
entity.Attributes["lastusedon"] = entity.Attributes["gbs_lastusedonoriginal"];
service.Update(entity);
}
}
catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occured in the plug-in.", ex);
}
}
The exception I get is:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An error occured in the plug-in.Detail:
-2147220891 OperationStatus 0 SubErrorCode -2146233088 An error occured in the plug-in.
2015-01-15T05:34:00.1772929Z[PreValidationMarketingList.Plugins: PreValidationMarketingList.Plugins.PreValidateMarketingListCreate] [5454a088-749c-e411-b3df-6c3be5a83130: PreValidateMarketingListCreate]
Entered PreValidationMarketingList.Plugins.PreValidateMarketingListCreate.Execute(), Correlation Id: 6d3ed105-f9c4-4006-9c80-08abd97c0140, Initiating User: 5e1b0493-d07b-e411-b592-f0921c199288 PreValidationMarketingList.Plugins.PreValidateMarketingListCreate is firing for Entity: list, Message: Create, Correlation Id: 6d3ed105-f9c4-4006-9c80-08abd97c0140, Initiating User: 5e1b0493-d07b-e411-b592-f0921c199288 Exiting PreValidationMarketingList.Plugins.PreValidateMarketingListCreate.Execute(), Correlation Id: 6d3ed105-f9c4-4006-9c80-08abd97c0140, Initiating User: 5e1b0493-d07b-e411-b592-f0921c199288
What am I doing wrong?In crm 2013 how do I set one field to equal another field if both of them are datetimes?