Skip to main content

Notifications

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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
dkrishna Profile Picture

dkrishna 6

Featured topics

Product updates

Dynamics 365 release plans