I am getting the following errors when I am doing the mass update on the Case Object in Salesforce.
casesynctrigger: system.limitexception: too many future calls: 51
The reason for this error I saw is the Apex class and Trigger which I created for syncing the data between Salesforce and Website. Below are the codes of the Apex class and Trigger.
Apex Class
public class GGUWSCall
{
private static gguEduIntegration.SFDCHandlerPort login(){
gguEduIntegration.SFDCHandlerPort port = new gguEduIntegration.SFDCHandlerPort();
port.inputHttpHeaders_x = new Map<String, String>();
Blob headerValue = Blob.valueOf(GGUSettings.USERNAME + ':' + GGUSettings.PASSWORD );
String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
port.inputHttpHeaders_x.put('Authorization', authorizationHeader);
port.inputHttpHeaders_x.put('Content-Type', 'text/xml; charset=utf-8');
return port;
}
@Future(callout=true)
public static void syncCase(String caseId, String status, String resolution
, String resolutionMethod, String closedDate, String commentsToSubmitter)
{
gguEduIntegration.SFDCHandlerPort port = login();
port.updateCase(caseId, status, resolution, resolutionMethod, closedDate, commentsToSubmitter);
}
}
Apex Trigger
trigger CaseSyncTrigger on Case (after update) {
for (Case caseNew : Trigger.new) {
GGUWSCall.syncCase(caseNew.CaseID__c, caseNew.Status, caseNew.Resolution__c, caseNew.ResolutionMethod__c
, caseNew.ClosedDate != null ? caseNew.ClosedDate.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'') : ''
, caseNew.Comments_to_Submitter__c);
//System.debug(Logginglevel.INFO, 'caseId: '+caseNew.CaseID__c+' status: '+caseNew.Status + ' resolution: '+caseNew.Resolution__c+ ' resolutionMethod: '+
//caseNew.ResolutionMethod__c + ' closeDate: '+(caseNew.ClosedDate!=null?caseNew.ClosedDate.format('yyyy-MM-dd\'T\'hh:mm:ss\'Z\''):''));
}
}
Can somebody please help how I can avoid getting the Error.
casesynctrigger: system.limitexception: too many future calls: 51
Thanks
Kamaldeep