You need to sign in to do that
Don't have an account?
MPBSL
How to deactivate users after Inactive Perion
Hi,
I have to deactivate users who have not logged into Salesforce since last 60 days but prior to that I have to send them an email from Apex class on their 53rd day of no logging. I want to perform both functionality in same batch class i.e send email on 53 days criteria to users and inactive users who have completed 60 days mark.
Can we call execute method twice?
Any help would be good.
Thanks,
Mayank Pant
Hi,
Why you need to execute method twice? Just query all users, query locator will return 200(default) user records. In execute() method, check if user has not logged in since 53 days, make a set of such users, also check for users who have not loggged in since 60 days and save them in other set. Now, send email to users of first set (i.e. users who have not logged in since last 53 days) and in-activate users in second set (i.e. users who have not logged in since last 60 days).
Also, you can schedule this batch job using apex scheduler to run every day at your specified time.
Let me know if you have any other question around this.
Happy to help you!
Regards,
Digamber Prasad
All Answers
Hi,
Why you need to execute method twice? Just query all users, query locator will return 200(default) user records. In execute() method, check if user has not logged in since 53 days, make a set of such users, also check for users who have not loggged in since 60 days and save them in other set. Now, send email to users of first set (i.e. users who have not logged in since last 53 days) and in-activate users in second set (i.e. users who have not logged in since last 60 days).
Also, you can schedule this batch job using apex scheduler to run every day at your specified time.
Let me know if you have any other question around this.
Happy to help you!
Regards,
Digamber Prasad
Hi,
Its really a good solution. One more assistance I need from your.
Is there a way in which we can find user records which failed when marked as inactive(update failed) due to any reason in execute block?
Thanks,
Mayank Pant
Hi,
Below code snippet should help you to handle each records of user update operation
Please let me know if it doesn't work for you.
Happy to help you!
Regards,
Digamber Prasad