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
AngrySlothAngrySloth 

Running APEX code when a record becomes unlocked

I am looking for a way to run some apex code when a recod ( in this case an Opportunity ) which is locked by an approval process becomes unlocked. Basically I would like to post some chatter messages when someone presses the unlock button on the record.  I have tried to catch this in an Opportunity trigger, but this button appears to not modify the opportunity record, thus the trigger does not fire.  I need to let the original approver know that the record was unlocked thus what was approved may now change.  Any help would be greatly appreciated.  Thanks
Shazib MahmoodShazib Mahmood
http://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_approval_locks_unlocks.htm#rn_apex_approval_locks_unlocks

The other brute force way would be to replace the unlock feature of salesforce by custom button. Where you control the swtiching between editabled and read only layouts via record types.