0

Is there a way to re-lock a record immediately after it has been approved via an Approval Process (in the same transaction)? It seems like a simple thing to do via a Trigger but I have an After Update (and Before Update for good measure) Trigger that tries to lock the record using Approval.lock but it fails without throwing an error. Subsequent updates to the record will lock it, showing that the Trigger criteria are correct.

Notes:

Despite Unlock the record for editing being the first Action in the "Final Approval Actions" list of the Approval Process, the record shows as locked when looked at via Approval.isLocked() before my re-locking code runs.

I would prefer not to use a separate Read-Only layout to get around this issue.

I would prefer not to use setup a time-based Workflow to touch the record shortly after the record is approved.

Steps performed:

  1. User submits the record for Approval (record is locked)
  2. Eligible approver hits the Approve button
  3. The Final Approval Actions has an Action that unlocks the record along with multiple field updates (one of which changes the Stage Name to a value which should then get the record locked via custom Trigger code)
  4. Field updates from the Final Approval Actions cause the Trigger to run - it finds that the Stage Name has changed to a specific value to it tries to lock the record
  5. The page then loads up showing that the record is unlocked without it seeming to flipflop between locked and unlocked in the transaction's Field History
2
  • can you provide some steps, like how you are submitting for approval, what happens after approver approves this request and when you want to lock the record Mar 12, 2018 at 19:44
  • @SantanuBoral I have updated the question with the steps performed.
    – Haphazard
    Mar 12, 2018 at 19:57

1 Answer 1

0

I would you suggest that in the Final approval action, make this record as unlock for editing.

Or, otherwise, in the approval step you will update the field which will fire trigger to perform the action.

You will do some updates and finally from the trigger you will finally lock the record.

3
  • Thanks for the response but I believe you are suggesting that I do what I am already doing. The Trigger is trying to lock the record but it does not work in that Approval Process transaction.
    – Haphazard
    Mar 12, 2018 at 20:08
  • If you have field updates then, be sure to select this checkbox Re-evaluate Workflow Rules after Field Change Mar 12, 2018 at 20:11
  • You don't appear to understand the issue. Your solution is a restatement of the steps I listed out.
    – Haphazard
    Mar 14, 2018 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .