Hello All, I am having trouble with a plugin I am working on. It is a synchronous update plugin from the Opportunity entity that when a condition is met will circle through the children entities (called dds_opportunity_product_line or OPLs in this example) and update those related to this opportunity. When I make the triggering update on the Opportunity I get this error: An error occured while processing this request. User with ID a01c391b-d837-e411-8744-6c3be5a8de30 does not have Update permissions for the dds_manager_sales_price_discount_limit attribute in the dds_opportunity_product_line entity. The dds_opportunity_product_lineid of the record is This field is setup for field security and this user does not have access, I understand that from the error, but this field is not changing with the plugin, my plugin code below. The trigger is when the field on Opportunity 'dds_split_deal_opportunity' is changed. When I step through the code it looks as if my plugin is trying to update the entire child record instead of just the three fields I am changing. Thank you public static void UpdateOPLsOnchangeofOpty(Entity opportunity, IOrganizationService orgService) { var SplitdealOption = opportunity.GetAttributeValue ("dds_split_deal_opportunity"); using (OrganizationServiceContext orgContext = new Microsoft.Xrm.Sdk.Client.OrganizationServiceContext(orgService)) { var OProductLineItems = orgContext.CreateQuery("dds_opportunity_product_line").Where(p => p.GetAttributeValue ("dds_opportunity_name") == opportunity.ToEntityReference()).ToList (); foreach (var OPLs in OProductLineItems) { if (opportunity.GetAttributeValue ("dds_split_deal_opportunity").Value == 1) { OPLs["dds_split_deal_opl"] = SplitdealOption; OPLs["dds_split_percent_opl"] = 0.00; OPLs["dds_split_with_opl"] = opportunity.GetAttributeValue ("ownerid"); orgContext.UpdateObject(OPLs); } else { OPLs["dds_split_deal_opl"] = SplitdealOption; OPLs["dds_split_percent_opl"] = opportunity.GetAttributeValue ("dds_split_percentage_on_opportunity"); OPLs["dds_split_with_opl"] = opportunity.GetAttributeValue ("dds_split_with"); orgContext.UpdateObject(OPLs); } } orgContext.SaveChanges(); } }
↧