function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
camelUsercamelUser 

Process builder user password

I'm looking to create a process that will trigger an apex class when the user password is X number days away from expiring (only trigger once not over and over)  is this possible? I know SF has an email flow but that's not what I'm looking for.

Is it possible to use the process builder for this?
Best Answer chosen by camelUser
Raj VakatiRaj Vakati
You can do it this with either process builder or workflow  / with apex also 


Please refer this link for how to do it with workflow or process builder

https://automationchampion.com/2014/02/17/email-notification-on-password-expiration/
http://sfdcgurukul.blogspot.com/2014/02/salesforce-winter14-release-features.html

If you want to do it with apex code you need to create apex scheduler  job that runs every day 
 
global class expireNotify implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        Date d = Date.today();
        String soql = 'SELECT Expiry_Date__c, Name, Email_Address__c FROM Member__c WHERE Expiry_Date__c =: d';
        return Database.getQueryLocator(soql);
    }
   
    global void execute(Database.BatchableContext bc, List<Member__c> recs) {
        List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
        for(Member__c m : recs) {
            List<String> toAddresses = new List<String>();           
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            toAddresses.add(m.Email_Address__c);
            mail.setToAddresses(toAddresses);
            mail.setSubject('Welcome to Sweet 16 Siebel Batch');
            String messageBody = '<html><body>Hi ' + m.Name + ',<br>Your account Expires today. <br>Kindly contact your administrator.<br><br><b>Regards,</b><br>Magulan D</body></html>';
            mail.setHtmlBody(messageBody); 
            mailList.add(mail);          
        } 
        Messaging.sendEmail(mailList);
    }
   
    global void finish(Database.BatchableContext bc) {
    }
}


Refer this link 
http://www.infallibletechie.com/2013/02/expiry-notification-through-email-using.html