Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Create an OpportunityProduct record as part of a Product Bundle

$
0
0

Hi,

I'm trying to create an OpportunityProduct record that is the child of a OpportunityProduct of the type Bundle. The OpportunityProduct is created perfectly fine with all it's associations to the parent Bundle and parent ProductAssociation. However, it seems impossible to set the ProductTypeCode field to the value "Optional Bundle Product". It stays at the default of Product.

I also tried to modify the value of the field with Scribe but that didn't work either. 

Anyone an idea?

My code:

                            Entity newOpportunityProduct = new Entity("opportunityproduct");
                            newOpportunityProduct["opportunityid"] = opportunity;
                            newOpportunityProduct["parentbundleid"] = opportunityProductBundel.Id;
                            newOpportunityProduct["productid"] = product2;
                            newOpportunityProduct["uomid"] = uom;
                            newOpportunityProduct["quantity"] = associatedProduct["quantity"];
                            newOpportunityProduct["productassociationid"] = associatedProduct.Id;
                            if (associatedProduct.GetAttributeValue<OptionSetValue>("productisrequired").Value == 0)
                            {
                                newOpportunityProduct["producttypecode"] = new OptionSetValue(4);
                            } else
                            {
                                newOpportunityProduct["producttypecode"] = new OptionSetValue(3);
                            }
                            service.Create(newOpportunityProduct);



Viewing all articles
Browse latest Browse all 3363

Trending Articles