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.
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
- Create one Text field in User object
- Create Schedule Trigger Flow
- Create New Resource
- 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.
1.2. Select Text as a field type → Click Next
1.2.1. Field Label : Note
1.2.2. Length : 50
1.3. Click Next , Next & Save.
2. CREATE SCHEDULE TRIGGERED FLOW
2.1. From the Quick find search and select Flows → Click New Flow.
2.2. Select Schedule-Triggered flow → Click Create.
2.3. Set a schedule to run the flow.
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
3.1.4. Click Done.
4. Add decision element
4.1. Select (+) icon → Select Decision Element.
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
4.5. Click Done.
5. Add Update Records Element
5.1 Select (+) icon → Select Update Records Element.
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
5.5. Click Save and Activate the Flow.
LIMITATIONS OF DEACTIVATING USERS USING FLOW
We can’t deactivate the following users :
- Default lead owner.
- Default case owner.
- Users in custom hierarchy fields.
- Workflow email alert recipients.
- 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