Using Flow to Freeze Users

Using Flow to Freeze Users

There are numerous scenarios in which you might need to restrict users from logging into the Salesforce environment. In some of these cases, you may not want to deactivate the users, or you cannot deactivate them immediately. For instance, if you are in the middle of a critical deployment, you may want to prevent users from logging in to Salesforce. In these situations, you can freeze users instead of deactivating them.

It is possible to freeze a user using the Freeze button on the user page. If you know what this button is doing, you can replicate it using flow too. This can save you a lot of time if you want to automate the process or freeze multiple users at once.

Standard Button to Freeze Users

Logic Behind the Freeze Button

There is an object called UserLogin, which shows if a specific user is frozen or not. When you hit the Freeze button on the user layout, it updates the UserLogin record related to that user. This object has an editable boolean field called isFrozen and the Freeze button marks this checkbox.

If a user is already frozen, you will see the Unfreeze button on the user layout. The logic is the same, it unmarks the isFrozen checkbox field.

It is worth mentioning that freezing users doesn't make their licenses available for use in your environment. Moreover, it is possible to freeze any kind of active or inactive users.

After knowing how these buttons are working, it is possible and easy to replicate this process using Salesforce Flow.

How to Build a Flow to Freeze Users

Let's build a screen flow that freezes multiple users at once.

1- Add a screen element with a selection component. In this example, let's use the lookup input component. You can use any user lookup field from your system. For instance, ManagerId field from the User object can be used.

Then, add a toggle component to choose freeze or unfreeze users. This is completely optional but if you are building a flow to freeze users, you may want to give an option to unfreeze the users as well.

Screen to Freeze or Unfreeze Users

2- Add a decision element to check what to do (freeze or unfreeze).

Decision to Check What to Do

3- Lookup element stores the selected records' ids. This is exactly what you need in order to freeze or unfreeze the users. Add an Update Records element and use the In operator to update the UserLogin records for those selected users. Clone this action for the unfreeze part of the flow. Don't forget that in that case you have to update the isFrozen field to false.

UserLogin Object to Freeze Users

4- Add success and error screens to display whether the process was successful or encountered an error.

At the end, your flow should look like this.

End of the Flow

Improvements

This was a simple example of freezing/unfreezing Salesforce users. It is possible to improve the flow in many ways. For instance, you can add a profile or role selection and then freeze all the users under the selected profile/role. This can save a lot of time.

On the other hand, it is important to know which users are frozen. Therefore, you can add a screen that displays a list of frozen users. So that you can select multiple users and unfreeze them at once.

It is important to mention that UserLogin object stores one more information: isPasswordLocked. This boolean field shows if the password of a specific user is locked. In order to unlock the password, you can unmark this field.

2 Comments

  1. Hi. I'm trying to limit the user freezing action (IsFRozen field) by validation rule, but I haven't been successful. I tried to apply the above concept in a Record Triggered Flow but it doesn't appear to select the User Login object. Would this solution be possible only via Screen Flow?

    Thank you very much in advance.

Leave a Reply

Your email address will not be published.


*