You need to sign in to do that
Don't have an account?
JennM
insert opportunity product
How do you insert an opportunity product? The schema is very confusing, I think that I would find the PricebookEntryID and insert that? But, I am getting an error that the PricebookEntryID is of the wrong type (MALFORMED_ID, Price Book Entry ID: id value of incorrect type: 01us0000001eOEkIAM)
opportunityId = newopp.id,
Quantity = 1,
ServiceDate = l.Donation_Close_Date__c,
PricebookEntryId =
OpportunityLineItem newoppprod = new OpportunityLineItem('01us0000001eOEkIAM');insert newoppprod;
There are lots of requirements for inserting opportunitylineitem records that aren't necessarily apparent at first glance, a couple of them to check into:
1) Is the PricebookEntryId you are using referring to a PricebookEntry object in the same Pricebook that the newopp opportunity object has set according to its Pricebook2Id field?
2) Are all the objects "active" , i.e. the Product2, Pricebook2 and PricebookEntry objects? They all have "IsActive" fields which need to be true I believe.
All Answers
The id looks okay, but here is what the statements would look like:
Generally you will also need a UnitPrice specified as well as all that.
Jeremy
Thanks. Somehow my post got messed up, but I have the same thing. Is it failing because I didn't put in a unit price? Why is the error saying the PricebookEntryID is the wrong type?
There are lots of requirements for inserting opportunitylineitem records that aren't necessarily apparent at first glance, a couple of them to check into:
1) Is the PricebookEntryId you are using referring to a PricebookEntry object in the same Pricebook that the newopp opportunity object has set according to its Pricebook2Id field?
2) Are all the objects "active" , i.e. the Product2, Pricebook2 and PricebookEntry objects? They all have "IsActive" fields which need to be true I believe.
Thanks. I needed to insert the Pricebook2ID when I was adding the opportunity and then the newoppprod worked!