Auto-Lock Records with Process Builder

Auto-Lock Records with Process Builder

I eventually get this request at every company I’ve worked with. I want to be able to “lock” a record after some sort of criteria. Sometimes it’s really easy and you’re able to simply create a validation rule that says if the record matches x criteria throw an error. Sometimes, it can be more complicated than that. My favorite reason is they want to prevent the user from editing the record at all, not just throw an error when they try to save the change.

Their argument is valid, their point is it’s more user friendly and a better user experience to prevent the user from using the edit button than allow the user to enter the edit screen, make a bunch of changes, and then get frustrated by receiving an error.

This method can be really useful for records that have a high compliance need. Records that absolutely you don’t want people to edit after the records meets your criteria.

The Components

There are only two items we need:

  1. Approval Process to lock the record
  2. Process to Submit Record to the Approval Process

Approval Process

The Approval process is very simple. We’re going to use a formula as the Approval criteria. The formula is simply going to be “false.” This way a user cannot accidentally submit a record into this approval. It will only be submitted using the process we created.

We’ll also only have a single Approval Step. We’ll have all records enter this step and if it doesn’t meet the criteria we’ll approve the record. Again, we’ll use a formula for the step criteria and make it false. This way every record that gets submitted will fail to meet the step criteria and just get approved.

Approval process with a single step

Approval process with a single step

Process Builder

The Process is also going to be really simple. Whatever your criteria is for when you want to lock the record you should set as the criteria node. That’s the blue diamond – think of it like a Workflow rule.

Next, we’ll need to add an action. We’ll add the action “Submit for Approval.” We’ll select a specific approval process, the one we just created. Here’s the important part, you’ll want to check the box to skip the entry criteria. Remember, the entry criteria would not accept any record. By skipping the criteria for the Approval process the record will get run through the approval steps.

 

Process Builder to submit for approval

Process Builder to submit for approval

Conclusions

That’s it! We’re done! Isn’t that simple? Now you can lock the record from editing whenever a record meets a set of criteria without having to write any validation rules.

Considerations:

Anyone who as “Modify All” on the object will be able to “unlock” the record to edit it. You may want to enable track history so to capture who unlocked a record.

You can also put a “delay” in the record locking. Instead of making it a “immediate” action, you can schedule the action based on some date on your record.

Showing 2 comments
  • Kristi G
    Reply

    This seems interesting – is your use case that the record should then be locked forever? IE: A week past the Close Date on an Opp, it can no longer be modified?

    • Brian Kwong
      Reply

      Kristi,

      You’re right or for a long period of time that requires someone with “modify all” perms on that object to “unlock” the record.

      It could be something like a authorization request or maybe a expense report.

      Or like you said you want to make sure the Opportunity cannot be edited after some set of criteria.

Leave a Reply