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 Microsoft Employee

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans