Hi,
I'm trying to create a plugin which will take set an entity to a dynamic value based on the primary entity's Id. Essentially, when I create a new 'opportunity' entity, I want to update a text field containing a related url. I think this should be quite simple, and I can get this to work when creating a new 'opportunity', but for some reason running the workflow on an existing 'opportunity' gives the following error: "The given key was not present in the dictionary".
I have seen similar issues online, but nothing that quite solved this, can anyone help?
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
OrganizationServiceContext ctx = new OrganizationServiceContext(service);
Entity targetEntity = (Entity)context.InputParameters["Target"];
{
//retrieve Record GUID
Guid recordId = (Guid)context.PrimaryEntityId;
//Set Field Value = url + recordId
targetEntity["web_url"] = "https://website.com/" + recordId;
service.Update(targetEntity);
}
*This post is locked for comments
I have the same question (0)