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
SanchSanch 

Salesforce BUG: "Save and New" Button is messing up Trigger.Old???

Hi All,

 

I have an object called Notes where it has a look up to the Client(Account) Object. I have a trigger on after insert and update.

 

For update, I am checking the old Client lookup value to the new one and doing some processing for that. But the Trigger.Old[i] only return's the Id, OwnerId and the isDeleted flag when I click "Save and New" Button and it return's the whole object when I click "Save". As a result I am getting an error. This seems like a salesforce bug, but I am just wondering if anyone have come across this before? Thanks.

 

The error message is:

 

 

Validation Errors While Saving Record(s)
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger NotesSharing caused an unexpected exception, contact your administrator: NotesSharing: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.NotesSharing: line 61, column 4". 
The error message occurs when I access Trigger.Old[i].Client__c. This works fine for Save, but it doesn't have the Client__c field value for Save and New. Does anyone know why? Thanks.
Sanch.

 

 

 

HarmpieHarmpie

(Just a guess) Did you try Trigger.oldmap.get(id).Client__c ?