Hello,
I am running into an issue with a plugin I am writing. My goal is to update a child record (dds_opportunity_product_line) based on the parent (opportunity). The field is named the same in both entities and is a global option set (dds_dsp_commission_type). The entity reference "opportunity" is to my post image which contains all fields of the Opportunity. When I debug the code I get the below error when I do the update towards the end. Thank you.
ERROR:
Incorrect attribute value type System.Int32
public static void UpdateCommissionType(Entity opportunity, IOrganizationService orgService)
{
var SplitdealOption = opportunity.GetAttributeValue<OptionSetValue>("dds_dsp_commission_type");
using (OrganizationServiceContext orgContext = new Microsoft.Xrm.Sdk.Client.OrganizationServiceContext(orgService))
{
var OProductLineItems = orgContext.CreateQuery("dds_opportunity_product_line").Where(p =>
p.GetAttributeValue<EntityReference>("dds_opportunity_name") == opportunity.ToEntityReference()).ToList<Entity>();
foreach (var OPLs in OProductLineItems)
{
var retFields = orgService.Retrieve("dds_opportunity_product_line", OPLs.Id, new ColumnSet("dds_dsp_commission_type", "dds_opportunity_product_lineid"));
var updOPL = new Entity("dds_opportunity_product_line");
updOPL.Id = retFields.Id;
updOPL.Attributes.Add("dds_dsp_commission_type", SplitdealOption.Value);
orgService.Update(updOPL);
}
orgContext.SaveChanges();
}
}
*This post is locked for comments