0

We have a requirement to send email reminder to community user to login and activate his account if he has not logged in within 24 hours.

we tried to create a time based workflow based on user object , field: last login date is null and user record created date time is > 24 hours , send email reminders.

But time based trigger on last login date field of user doesnt work. Is there any other reliable way to find out if a community user has not logged in for 24 hours without writing apex?

1 Answer 1

0

I think that perhaps is better to do a batch operation for this. If you have some kind of notification service class you can really manage this well.

public class BatchableCommunityUserEmail implements Database.Batchable<SObject> {
    String query;

    public BatchableCommunityUserEmail() {
        List<String> soql = new List<String>();
        soql.add('SELECT ...');
        soql.add('FROM User ');
        soql.add('WHERE  ...');
        query = String.join(soql, '');
    }

    public Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(query);
    }

    public void execute(Database.BatchableContext BC, List<Opportunity> opportunities) {

      // If you have a notification services you can use it here
      // if not, you can Messaging.SingleEmailMessage or 
      // a List<Messaging.SingleEmailMessage>

    public void finish(Database.BatchableContext BC) {

    }

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .