back to blog
DEACTIVATING USERS
April 22 2024 • 10 min read

BUSINESS CHALLENGE

To maintain low licensing costs, it's advisable to deactivate users who aren't actively using Salesforce on a regular basis. The following flow can be implemented to deactivate users who have been inactive for a specified number of days.

picture1

ASSUMPTIONS

This flow can be used only for non-Admin non-Developer users. Admin / Developer users have to be deactivated manually as they will have flows and other development objects assigned to them.

STEPS TO ACHIEVE THE REQUIREMENT

  1. Create one Text field in User object
  2. Create Schedule Trigger Flow
  3. Create New Resource
  4. Add a decision element, Here we are checking lastlogindate

  5.  Add update records element, Using update records we Can update values

1. Create one Text field in User object

1.1.  Go to set up → Click Object Manager  →  Select User Object and then go to Field & Relationships.

picture2

1.2.  Select Text as a field type → Click Next

                       1.2.1.   Field Label : Note

                       1.2.2.   Length : 50

picture3

             1.3.  Click Next , Next & Save.

2. CREATE SCHEDULE TRIGGERED FLOW

             2.1.  From the Quick find search and select Flows → Click New Flow.

picture4

            2.2.  Select Schedule-Triggered flow  → Click Create.

picture6

         2.3.  Set a schedule to run the flow.

picture7

             2.4.  Select User as an  Object

            2.5.  Select All conditions are met (AND) as a condition requirement 

                    and add the following :

2.5.1 IsActive - Equals- True

 2.5.2 UserType -Equals- Standard

3. Create New Resource

3.1.  Click the New Resource button on the left side of the canvas  and  

                    enter the following:

                           3.1.1.  API Name : lastlogindatecheck

                           3.1.2.  Data Type :Date/Time

                           3.1.3.  Resource Type : Formula with Today() - 50 days

picture9

                           3.1.4.  Click Done.        

4. Add  decision element

              4.1.   Select (+) icon → Select Decision Element. 

picture10

4.2 Enter Label as Users Logged in more than 50 days ago

4.3 Outcome Details as TRUE user logged in more than 50 days ago  API Name will be auto populated→All conditions Are  Met(AND).

4.4 Enter Resource as $Record>lastlogindate Less than or Equal   lastlogindatecheck

picture11

    4.5.   Click Done.

5.  Add  Update Records Element

           5.1  Select (+) icon → Select Update Records Element

picture12

5.2.  Enter Label as Update user Records API Name will be auto populated.

5.3.  Select Use the user $Record global variable 

5.4.  Set field values for the user record     

5.4.1. Isactive  =  False

5.4.2. Note   =  who didn’t login for more than 50 days

picture13

5.5.  Click Save and Activate the Flow.

LIMITATIONS OF DEACTIVATING USERS USING FLOW

We can’t deactivate the following users : 

  1. Default lead owner.
  2. Default case owner.
  3. Users in custom hierarchy fields.
  4. Workflow email alert recipients.
  5. Customer Portal Administrator users.

We can deactivate other users except the above users, but we can’t remove them from account teams and opportunity teams using this Flow.

For more details refer the following link( link )

WRAPPING IT UP

In this blog we have explained how to deactivate  users automatically who have never logged in for more than 50 days using a Schedule Triggered flow.

Leave a Comment

Your email address will not be published

© 2024 Digital Biz Tech