In Salesforce user management, we cannot delete a user once it is created, so we deactivate the user account to refrain the user from having access to the organization.
We can automate the process of user deactivation using the flows, and in this Salesforce tutorial, we will learn to Auto-Deactivate Users with Schedule-Triggered Flow in Salesforce.
Create a Schedule trigger flow to deactivate Users in Salesforce
To auto-deactivate users in Salesforce, we will create a Schedule-triggered flow in the following steps.
In this schedule trigger flow, we will set conditions to deactivate the user, where if the user hasn’t logged in for the last 60 days, his account will be deactivated.
1. Navigate to the setup of Salesforce, and in the Quick Find box, search, then select Flows under the heading Process Automation.
2. In the flows setup window, click on the button New Flow.
3. Select the option Schedule-Triggered Flow, and click Create.

4. Select the Start Date and Start time for the schedule of the trigger flow. After this, select the frequency from the options Once, Daily, and weekly.
5. Select the Object as User. In the Condition requirements, set the Field as IsActive, Operator as Equals, and Value as True.

6. Create a New Resource for the formula that we will use to find the last login date.
Enter the below details in the New Resource.
- Enter the Resource Type as Formula.
- Enter API Name as Last_login.
- Select Data Type as Date Time.
- In the Formula section, enter the formula NOW() – 60. This will subtract the current date from 60 days.
- At last, click Done.

7. Add a decision element to the flow; in this, we will add the conditions for the last login date.
- Enter the Label and the API Name for the decision element.
- Enter the label and Outcome API name in the Outcome Details section.
- In the Condition Requirements, select