You need to sign in to do that
Don't have an account?

system.limitexception: too many future calls: 51
I am in process of developing a code to get the information from the Case Object and update it on our Website. I have developed all the code (Apex Classes and Apex Trigger) and the code is working well but its look like my code is not bulkified and its hitting the Governance Limit whenever I am mass updating the Case object. Can somebody please help me to bulkify the code.
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);
}
}
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\''):''));
}
}
Thanks
Kamaldeep
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);
}
}
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\''):''));
}
}
Thanks
Kamaldeep
trigger CaseSyncTrigger on Case (after update) {
GGUWSCall.syncCase(Trigger.New);
}
@Future(callout=true)
public static void syncCase(List<Cases> newCases)
{
gguEduIntegration.SFDCHandlerPort port = login();
for(Case newCase: newCases){
//write code here to get caseId,Status etc from newCase.
port.updateCase(caseId, status, resolution, resolutionMethod, closedDate, commentsToSubmitter);
}
}
Hope this helps. Let me know?