You need to sign in to do that
Don't have an account?
Jesper Kristensen
PricebookEntryId is null in OpportunityLineItem before update trigger in Winter 15
A new problem has suddenly appeared this week in our sandboxes. When I update an OpportunityLineItem, my "before update" trigger sees a null value in the PricebookEntryId field. But this is an update to an existing OpportunityLineItem, so it should have an associated PricebookEntry. When I extract the record in the data loader, it does in fact have a PricebookEntryId. This worked flawlessly last week. Our sandboxes run on CS17, and I can see that Winter 15 is released this weekend, so I guess it is related to that release. It seems like a bug in the platform. Does anybody know of a workaround? We are in the finishing phase of a large project, and our UAT testing is heavily impacted by this, since users are no longer able to make any updates to existing OpportunityLineItems.
Since Winter 15 was developed (this monday) in sandbox we have the following error in SF internal code, but not our code. We will explain you an example.
We have a controller class with pricebookentryid in an opportunitylineitem update. We triggered the update in opportunitylineitem with a value in pricebookentryid.
Then, opportunitylineitem before update trigger started without pricebookentryid (=null).
We have found out that when the code executes a line with an update on an opportunity line item in a controller class, right before the OpportunityLineItem Before Update trigger gets executed, the pricebookEntry value gets lost (it becomes null). That doesn't happen with other OpportunityLineItem fields nor any other objects.
We have not got this problem before and now in production there is not any problem about it. We haven't change the code. There is the same code in sandbox an production. The code was deployed to production and it works. This only happens in sandbox.
Subject: Bug report Winter 15 release Sandbox: PriceBookEntryId is null when updating OpportunityLineItem through API
Description:
Hi,
I found a bug in the Winter 15 release (in sandbox). This is not a case asking for Development Support, so please do not direct me to the forums. Please escalate to appropriate resources.
When an existing OpportunityLineItem is updated through the API, or through other Triggers, the PricebookEntryId of the OpportunityLineItem in any resulting Trigger Context is null. In other words, even although the OpportuntyLineItem has a PricebookEntryID, it appears to be null in Apex Code context. This causes existing Triggers that used to work to fail.
When updating the same record though the UI, it has the correct Id.
I have added a simple trigger to illustrate this in our sandbox:
//---------
trigger oliTEST on OpportunityLineItem (before update) {
//System.Debug(Trigger.New);
For(OpportunityLineItem oli:Trigger.New){
System.Debug('PricebookEntryId: ' + oli.PricebookEntryId);
}
}
//---------------
If you update an existing OpportunityLineItem through the API and search the debug logs for "PricebookEntryId:" you will see that it appears to be null:
10:27:58.372 (372718397)|CODE_UNIT_STARTED|[EXTERNAL]|-REDACTED-|oliTEST on OpportunityLineItem trigger event BeforeUpdate for [00kK000000AxN46]
10:27:58.373 (373616800)|USER_DEBUG|[4]|DEBUG|PricebookEntryId: null
Sample code for Execute Anonymously (the id is safe to update for SFDC staff):
//-------------
OpportunityLineItem oli = new OpportunityLineItem (id = '|-REDACTED-');
update oli;
//----------------
I have granted login access in the sandbox.
I also found other users who are affected, samples here:
https://developer.salesforce.com/forums?id=906F0000000AhsEIAS
https://developer.salesforce.com/forums/?id=906F0000000AhuoIAC
Please let me know if you have additional questions
If anyone has an update on this issue - related to Winter 15....
https://success.salesforce.com/issues_view?id=a1p30000000T5c9AAC