You need to sign in to do that
Don't have an account?
Our Man In Bananas
Error when locking a record in BeforeUpdate trigger
I need to lock a record in my trigger after a member of the systems team has changed it.
I tried this code:
The error I get is:
I need to lock the record as once this part of the process has been reached there should never be any need to edit it.
But it has to be unlocked after it has been approved by the Line manager in order that systems can convert the request into a demand (by changing the status which kicks off the BeforeUpdate trigger).
in the Process Automation Settings this has been enabled
So what am I missing here and what is the correct way to do this in Apex?
I tried this code:
// Lock the request Approval.lock(rq.Id);rq is the record in my custom object.
The error I get is:
Apex trigger System_Change_Request_Events caused an unexpected exception, contact your administrator: System_Change_Request_Events: execution of BeforeUpdate caused by: System.UnexpectedException: null: Trigger.System_Change_Request_Events: line 315, column 1 line 315 is the one above that tries to lock the record.It saved the trigegr changes ok, so the method signature must be correct.
I need to lock the record as once this part of the process has been reached there should never be any need to edit it.
But it has to be unlocked after it has been approved by the Line manager in order that systems can convert the request into a demand (by changing the status which kicks off the BeforeUpdate trigger).
in the Process Automation Settings this has been enabled
So what am I missing here and what is the correct way to do this in Apex?
NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.