Background: In Winter '16, Salesforce introduced the Approval class for setting approval locks and unlocks through Apex (release notes). Since then, my company has been leveraging this functionality to permanently lock records that we no longer want users touching, for historic purposes. This seemed a better and more future-proof solution than a custom VR on each object that checked for changes to any field. Our primary use is to lock Opportunities after they've been marked as Closed Lost or Closed Won.
Issue: The director of one of our inside sales departments has been having issues with teams miscalssifiying records, or closing them pre-maturely, and has asked us for access to edit these locked records to fix the data. However, since Opportunities are used by multiple departments we are not interested in giving her the "Modify All" permission on that object which would allow her to edit all locked records in that object.
SO - According to the Salesforce Documentation for the Approval class:
Salesforce admins can edit locked records. Depending on your approval process configuration settings, an assigned approver can also edit locked records. Locks and unlocks that are set programmatically use the same record editability settings as other approval-process locks and unlocks.
However, the documentation does not make it clear how Salesforce determines this editability, other than that it uses the "same record editability settings as other approval-process locks...".
In our case, we have multiple different approval processes on the Opportunity object, two of which apply to her department, and 1 of which applies to a completely different department. Each of these has a different value for "Record Editability". 2 are Administrators ONLY, and one is Administrator and Approver.
She is not able to edit these records, and I cannot find any further documentation that would clarify if this functionality is possible or not while using the Approval class to lock records programmatically. I found another post on the Stack where another user seems to be reporting the same scenario, but wasn't very clear in his ask and never got a solid answer.
Ultimate Question: Is there some methodoly behind determining if/when a user can edit a record that was locked programmatically using the Approval.lock method, or a way to programmatically indicate who the "Approver" is so that I can set it and grant her access? Or is this just a flaw in the current Approval implementation that I can't work around?