Monday, November 24, 2014

How to escalate cases using Apex in Salesforce?

How to escalate cases using Apex in Salesforce? 

Here is the Sample Code:

Batch Class:

global class CaseEscalation implements Database.Batchable <sObject>{
    global Database.QueryLocator start(Database.BatchableContext bc){
        String SOQL = 'SELECT Id, IsEscalated FROM Case WHERE Status = \'High\' AND IsEscalated = False';
        return Database.getQueryLocator(SOQL);
    }
   
    global void execute(Database.BatchableContext bc, List<Case> caseList){
      list<Case> caseUpdatelist = new list<case();
        for(Case c : caseList){
            c.IsEscalated = true;
            caseUpdatelist .add(c);
        }
         if(caseUpdatelist .size()>0)
        update caseUpdatelist ;
    }
   
    global void finish(Database.BatchableContext bc){
    }
}

Schedulable Class:

global class CaseEscalationSchedule implements Schedulable{
    global void execute(SchedulableContext sc){
        CaseEscalation ce = new CaseEscalation();
        Database.executeBatch(ce);
    }
}




1 comments:

nick jones said...

good blog..
Malware Proctection

Post a Comment

 
| ,