In Salesforce we can set password policies and then User passwords expire in days we define(like 30, 60 etc) . The main problem with this approach is that user doesnot get any reminder email before password expiration date. After winter’14 Salesforce allows us to create workflow rule on User object. So we can use workflow to solve this problem. Before we go ahead,some configuration work need to be done.
1) Create an email template for workflow email notification. To do that follow the step
- Click on Name | Setup | Personal Setup | Email | My Template
- Click on “New Template“, I used “Custom (without using Letterhead)” template. Below are the screen shot for your reference
2) Set the Password Policies for your organization, To do that follow the below steps
- Click on Name | Setup | Administration Setup | Security Controls | Password Policies
- Select days for drop down “User passwords expire in“, In my case I selected 30 Days.
3) Create a flag i.e.a checkbox (Password Expiration notification) on User object, to check workflow entry criteria. For default value select Unchecked option.
We are good to go ahead, to create workflow for this follow the below steps
1) Click on Name | Setup | App Setup | Create | Workflow & Approvals | Workflow Rules.
2) Click on “New Rule“, It will redirect you to a new page
3) Select User object, Click on Next
4) Enter Rule Name, Evaluate the rule when a record is (Evaluate the rule when a record is created, and any time it’s edited to subsequently meet criteria – To create time dependent workflow) and enter Rule Criteria. Click on Save & Next.
5) Now add workflow immediate action (Field Update) and update flag “Password Expiration notification” to true. once done click on Save.
6) Now Add time trigger to send email alert after 29 days (It means on the 30th Day) of Last password change or reset and we will set flag to true (Password Expiration notification) also . To do this click on “Add Time Trigger“.
7) Set the length after how many days email notification should be sent i.e. in hours and days, I selected 29 days after “Last password change or Reset“.
Note:- Last password change or Reset is standard field, it’s automatically updated when you change or reset your password.
8) Add two action for time dependent workflow
- Email Alert
- Field update for flag “Password Expiration notification” to false.
Finally it will look like below screen shot, Click on Done and Activate this workflow.
Summary :- So workflow will be fired only when Flag ( We created on User Object) is set to false.Once workflow is fired it will set flag to true. After 29 Days time dependent trigger will fire and it will send an email alert to user and update set the flag to false, then it will meet the workflow entry criteria and queued in time dependent trigger to fire after 29days again.
It’s time to test it
To test this for one user record, set flag to true then set it to false, and it will queue action for you in time dependent workflow. if you want for all users try to update it with Data Loader( True then false). To check time dependent workflow queue Follow the path
- Click on Name | Setup | Administration Setup | Monitoring | Time–Based Workflow and search the queue.
Note:- Here I assume that user will change password on the 30th Day. For another solution you can write a schedulable batch class.