function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jesper KristensenJesper 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.
Hargobind_SinghHargobind_Singh
Saw another post, same topic. You should contact Salesforce support: https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Developer_Forums&criteria=OPENQUESTIONS&id=906F0000000AhuoIAC (https://developer.salesforce.com/forums/#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Developer_Forums&criteria=OPENQUESTIONS&id=906F0000000AhuoIAC)
Enara MarcosEnara Marcos
We have the same problem: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AiIcIAK

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.
Hargobind_SinghHargobind_Singh
Can you try to reach SFDC support with this problem ?

Enara MarcosEnara Marcos
We opened 2 cases in the client account, but SF closed it. Then, we opened a new one with our account (partner) and also SF closed it. The reason they said was that is a develop question and without any contact, they closed the case.  However, the case is about a SF internal code and not our code.
Arnt mongoDBArnt mongoDB
I can also verify this. I put in a simple test trigger for them to verify, I will also log a case (wish me luck).
Arnt mongoDBArnt mongoDB
So I logged the following case #10987398

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
cpebre3cpebre3
I am facing the same issue, it was working fine until today: when getting the PricebookEntryId from Opportunity Line Item trigger (before), it returns 'null'.

If anyone has an update on this issue - related to Winter 15....
Arnt mongoDBArnt mongoDB
It is not a know issue yet, but I hope it gets on that list, or is even fixed before.
Derrek HarrisonDerrek Harrison
I have hit this same critical issue and Salesforce says that their R&D team is currently working on the issue. I did not get any timeline update, but seeing as Winter '15 starts rolling out to production organizations on September 20th, I do hope this is addressed before then.
Arnt mongoDBArnt mongoDB
Update: This is now a know issue for Winter 15:
https://success.salesforce.com/issues_view?id=a1p30000000T5c9AAC
Derrek HarrisonDerrek Harrison
We just got an update from Salesforce that they are targeting September 23rd for rolling out a fix. This means that this bug may exist in Production environments for a few days for the NA1 pod as that pod is updated to Winter '15 on Septeber 19th.