web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics CRM 2015 plugin error

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans