One of the great things about Approval Processes is the ability to lock a record so that a user cannot modify that record. One of the hard things to work around is when a locked record needs to be opened up to be edited again, for instance if, during electronic signature, the customer rejects the signature since they want to negotiate.

Enter the Unlock Record Apex Action, available with Process Builder or Flow! It is as simple as adding in your logic, say the a Quote status is updated to Rejected, then unlock the Quote.

Additionally, you can use this in Flow too. Simply select your Apex Action and add the record Id you’d like to unlock.

And voila, your Quote is unlocked! You can leave it as simple as below, or you can add in logic, like ensuring the Opportunity is not Closed Won, or other things like that!

NOTE: If running Unlock Record Apex Action in Flow, it does respect User permissions. So if a User does not have the permission to Edit a Locked Record, then they will not be able to unlock the record by simply clicking a button that launches to a Flow. Use Process Builder as Process Builder runs in system mode. If the logic is too complex for Process Builder, have Process Builder call the Flow to handle the more complex logic and then it can unlock the record. When Flow is called from Process Builder, it runs in system mode as well.

3 comments

  1. Hi- this is a great tool, thank you! my users that don’t have the rights to unlock a record, are getting an error even if the Flow is run from Process Builder. Is there something I”m missing?

    The error message I get is: “An Apex error occurred: System.DmlException: Delete failed. First exception on row 0 with id XXXXXXXXXXXXXX; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []”

    1. Hi Fred,

      The apex error says Delete failed. This shouldn’t be deleting anything. Are you doing something else in your update? If you launch this from Process Builder, it should unlock no matter what. If you launch it from a button it will not work for someone who does not have the right access, that is until Spring 20, there is an update to allow the flow to run in system mode. I need to test it to confirm, but it should work in that mode for users who don’t have access.

      Rich

  2. Hi Rich- thanks for your help. You’re right, that is a strange error. It might have nothing to do with this bit of code. I will attempt to isolate the variables in a sandbox and test.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: