We’ve updated our component, check out the updated instructions here!

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.

9 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.

  3. Hi Rich,
    I am trying to use the Unlock function to unlock an opportunity that went through an approval process, but it seems to only do it for admins. I built a flow, set it to run in system mode (which you can do as of spring 2020), and created a url button that users can click to unlock their opportunity. However, it only works for admins. I’ve also tried incorporating the unlock action into an auto-launched flow that is triggered by process builder, but that only unlocks for admins too. Process builder simply ignores the unlocking action and moves on to the next record update for non-admins.

    Please let me know if I am missing anything.

    Thanks!
    Olya

    1. Hi Olya,

      If the record is locked, then out of the box, only those who are allowed to unlock records will be able to use it. It does, however, work with Process Builder in my configurations. So I have had a process unlock a record, for instance if you send out something for signature, you lock the record it sent (like a quote), but then if it is rejected or expired or cancelled, you unlock the record. I have used that with PB. I haven’t tested it in system mode, but will take a look when I get a chance and let you know. I would “think” that should work, but you’ll need to unlock it first before trying to make an update as a user, if that makes sense.

      Rich

  4. Hi Rich,
    Thank you so much for your quick reply! I have the Process builder triggered by a task creation and the PB is supposed to unlock the opportunity and update the stage as well as several fields on the opportunity, then update the task. The strange thing is that when I create the task, PB does everything perfectly (including unlocking the opp); however, when an end user creates a task the PB does everything EXCEPT the opportunity remains locked. So PB is able to update a locked opportunity when triggered by an end user (an end user without the modify all permission) but it’s not able to unlock the said opportunity. I hope that explanation makes sense!

    Thank you again!

    Olya

  5. Hi Rich
    This used to work for non admins for me. Currently when a non admin who has modify all rights on the KB object click the unlock button that triggers the flow to unlock the KB the non admin is now getting the same error below

    : “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 Jonathan,

      The component follows user security, so if they don’t have rights to edit a locked record (modify all), then they wouldn’t be able to use the unlock. We did come out with a new release of Flow Components and in the updated version we do have a capability now for you to allow users who don’t normally have the rights to unlock a record to be able to unlock the record. Please see the following article and let me know if that helps. https://englhardconsulting.com/flow-components-unlock-record/

      Rich

Leave a Reply

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

%d bloggers like this: