You need to sign in to do that
Don't have an account?
trinity
Update PriceBookEntryID after the Opportunity Line has already been created
I am trying to update PriceBookEntryID of an already created OpportunityLineItem. I am getting this error:
caused by: System.SObjectException: Field is not writeable: OpportunityLineItem.PricebookEntryId
Is it possible to update PriceBookEntryID after the OpportunityLineItem has already been created?
the field that you are trying to update is the primary key of the object.
The field is "closed", cant not be editable.
but.. what are u trying to do?
We are trying to change the product in Opportunity Line Item after it is created with some other product. Deleting and creating again takes significant amount of time in our instance because we have some custom code attached to Opportunity Line Item that adds additional steps in creation.
can u put your code please? its must easier.
Is there a reason you're not using a before insert trigger. That's generally where you put logic that catches one association and redirects it to another...
If this is something that's going to occur at anytime in the sales process based on conditional logic (ie on lineitem updates, not inserts) there's no way to avoid a clone - delete original - insert clone pattern except perhaps to reevaluate why you're replacing the pricebook entry in the first place. if it's for discounting logic, best to extend the opportunity line item rather than define separate pricebook entries.
u have to delete the record first, keep the information in code that u want to reuse in the new line item with the new product