• Mallik1221
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Can we assign cases to agents through omni channel without having service channels through coding?
Here is the apex class I wrote and scheduled but it is throwing an error.

global class LastLoginEmail2 implements Schedulable {
    global void execute(SchedulableContext SC) {
        List<User> uds =[SELECT Id, LastLoginDate, Email FROM User where IsActive=True];
        
        EmailTemplate et=[Select id from EmailTemplate where Name=:'Users_Please_login']; 
        Messaging.SingleEmailMessage[] mails = new Messaging.SingleEmailMessage[0];
        for(User u : uds){
            If( u.LastLoginDate<=System.today().addDays(-1)){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
                mail.setTargetObjectId(u.Id); 
                mail.setSenderDisplayName('Salesforce Support'); 
                mail.setUseSignature(false); 
                mail.setBccSender(false); 
                mail.setSaveAsActivity(false); 
                mail.setTemplateId(et.id); 
                mails.add(mail);
            }
            Messaging.sendEmail(mails);
        }
    }
}

Here is the error:
Scheduler: failed to execute scheduled job:class: common.apex.async.AsyncApexJobObject, reason: List has no rows for assignment to SObject

I tried it in different ways but still this error is coming, could anyone help me on this please.

Thanks
Here is the apex class I wrote and scheduled but it is throwing an error.

global class LastLoginEmail2 implements Schedulable {
    global void execute(SchedulableContext SC) {
        List<User> uds =[SELECT Id, LastLoginDate, Email FROM User where IsActive=True];
        
        EmailTemplate et=[Select id from EmailTemplate where Name=:'Users_Please_login']; 
        Messaging.SingleEmailMessage[] mails = new Messaging.SingleEmailMessage[0];
        for(User u : uds){
            If( u.LastLoginDate<=System.today().addDays(-1)){
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
                mail.setTargetObjectId(u.Id); 
                mail.setSenderDisplayName('Salesforce Support'); 
                mail.setUseSignature(false); 
                mail.setBccSender(false); 
                mail.setSaveAsActivity(false); 
                mail.setTemplateId(et.id); 
                mails.add(mail);
            }
            Messaging.sendEmail(mails);
        }
    }
}

Here is the error:
Scheduler: failed to execute scheduled job:class: common.apex.async.AsyncApexJobObject, reason: List has no rows for assignment to SObject

I tried it in different ways but still this error is coming, could anyone help me on this please.

Thanks
Hi All, 
When a last login user is greater than 30 days, then I want to send a automated email to the respective managers.
This can done by using
workflow
Process Builder
apex class
Please advice
Hi All,

I want to mask credit card number in Case Description field. Whenever case get created in sfdc if case description field contains any credit card number, I just wanted to mask credit card number. For example if anyone enter credit card number like 4346-7810-4356-6678 in case description, After saving the case Credit card number should be look like as xxxx-xxxx-xxxx-xxxx. I have also tried to write trigger on Case object. But it is not working properly. It is making all number as cross(x) in case description field. Please find below code:
Trigger:
trigger testMaskCC on Case(before insert){
 if(trigger.isBefore && trigger.isInsert){ 
        CreditCard_No_Masking_OnCase NewCase= new CreditCard_No_Masking_OnCase();
        NewCase.newCaseInsert(Trigger.new);
    }      
}


Trigger Class
public class CreditCard_No_Masking_OnCase{

    public void newCaseInsert(list<Case> newList){
    
    String reGexVisa='4[0-9]{12}(?:[0-9]{3})';
    Pattern regexPattern = Pattern.compile(reGexVisa);
        for(case cs : newList){
           String withOutSpec=(cs.description).replaceAll('[-, +]','');
           Matcher regexMatcher = regexPattern.matcher(withOutSpec);
            system.debug('-------------group count----'+regexMatcher.groupCount());
           while(regexMatcher.find()){
              Integer countGroup=0;
              String  matchValue=regexMatcher.group(countGroup);
              cs.description= String.valueOf(cs.description).replaceAll('[0-9]', 'X');
              countGroup++;
            }
        }
    }
}


And also I am using regex for idetifying different companies's credit card number like Visa Card: ^4[0-9]{12}(?:[0-9]{3})?$  Mastercard: ^5[1-5][0-9]{14}$.

Please help me to generalized Regex(I wanted to use one Regex to identify different comany's credit card instead of using different company's regex) and Mask the Credit Card number only.
Any Help in this regard would be much appriciated.

 
  • June 02, 2016
  • Like
  • 0