Hi, I created an update plugin, when I do the debugging , I can see the attributes get updated, but it doesn't reflect on the form or in the database. did I miss anything?
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new InvalidPluginExecutionException("localContext"); } IPluginExecutionContext context = localContext.PluginExecutionContext; IOrganizationService service = localContext.OrganizationService; if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity entity = (Entity)context.InputParameters["Target"]; if (entity.LogicalName == "contact") { Entity Contact = service.Retrieve("contact", entity.Id, new ColumnSet(true)); if (Contact.Attributes.Contains(" businessregistrationid") == true) { String contactid = entity.Id.ToString(); string registraionid = Contact.Attributes[" businessregistrationid"].ToString(); string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='contact'> <attribute name=' businessregistrationid' /> <attribute name=' brokerofrecord' /> <attribute name='contactid' /> <filter type='and'> <condition attribute=' businessregistrationid' operator='eq' value='" + registraionid + @"'/> </filter> </entity> </fetch>"; EntityCollection ec = service.RetrieveMultiple(new FetchExpression(fetchxml)); foreach (var c in ec.Entities) { if (c.Attributes["contactid"].ToString() == contactid) { c.Attributes[" brokerofrecord"] = 1; } else { c.Attributes[" brokerofrecord"] = 0; } } } } else { throw new InvalidPluginExecutionException("The account number can only be set by the system."); } } }
*This post is locked for comments