0

I am trying to write a trigger which will help me to fire a workflow. Since according to my condition the workflow is not meeting the entry criteria. According to my knowledge the workflow entry criteria only meets when its condition fields got updated but in my case the condition fields are not getting updated. So finally i have last option as trigger which will fire when any field get updated in record.

Here I am trying to send the Password Reset Notification to the user one day before expiry date.

Can anyone please help me how to achieve this.

trigger workflowtrigger on User (before update,after update) {
    for(User u : trigger.new){
        if(u.LastPasswordChangeDate!=trigger.oldMap.get(u.Id).LastPasswordChangeDate){
            System.debug('New-->'+u.LastPasswordChangeDate+'<-------'+trigger.oldMap.get(u.Id).LastPasswordChangeDate);
        }
        else{
            System.debug('#######SAME##############');
        }
    }
}
0

A trigger will only be fired when a record is updated. If you are looking to have something that will send an email confirmation at expiry_date - 1, then I would suggest a scheduled apex job to do this.

Details on scheduled apex can be found here: https://trailhead.salesforce.com/en/asynchronous_apex/async_apex_scheduled

0

You could try using the "Time-based work flow" to trigger the notification one day before the expiry based on "Last Password Change or Reset" parameter in the User object and the default password expiration policy for your org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.