Hi everyone,
Im trying to write the post images value of a field to another field once contact record is updated.
I get the following error
Unexpected exception from plug-in (Execute): ClassLibrary1.Class1: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Below is my code
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
string pretopic = string.Empty; string posttopic = string.Empty;
if (context.PreEntityImages.Contains("LeadTopicImage") && context.PreEntityImages["LeadTopicImage"] is Entity)
{
Entity preMessageImage = (Entity)context.PreEntityImages["LeadTopicImage"];
pretopic = (String)preMessageImage.Attributes["jobtitle"];
}
if (context.PostEntityImages.Contains("LeadTopicImage") && context.PostEntityImages["LeadTopicImage"] is Entity)
{
Entity postMessageImage = (Entity)context.PostEntityImages["LeadTopicImage"];
posttopic = (String)postMessageImage.Attributes["jobtitle"];
}
context.InputParameters.Contains("spousesname");
entity.Attributes.Add("spousesname",posttopic);
*This post is locked for comments