You need to sign in to do that
Don't have an account?
how to write iterable batch apex
Hi All,
Can anybody help me out with this?
this is the class for which batch apex is to be written..
global class SMSToLead{ @future (callout=true) public static void sendSMS(string phoneNUmber,string product,string OfficerName,list<string> lstFEcode) { system.debug('***phoneNUmber******'+phoneNUmber); system.debug('***product******'+product); system.debug('***OfficerName******'+OfficerName); String strurl='http://xxyyyzzz.fdf&to='+phoneNumber+'&text=Transaction+of+Rs.1234+made+&alert=1'; HttpRequest req=new HttpRequest(); req.setEndpoint(strurl); req.setMethod('POST'); string strbody='hi'; req.setBody(strbody); req.setCompressed(true); Http http=new Http(); HTTPResponse res=http.send(req); string strRes=res.getbody(); system.debug('**** Response is *****'+strRes); } @future (callout=true) public static void sendSMSTOFEMaster(list<string> lstFEcode) { system.debug('****insideFEmaster*****'+lstFEcode ); list<FE_Master__c> lstFEMaster = new list<FE_Master__c>(); lstFEMaster =[select id,contact_number__c,FE_Code__c from FE_Master__c where FE_Code__c IN:lstFEcode]; for(FE_Master__c objFEMaster:lstFEMaster ){ string FEMasterContact =string.Valueof(objFEMaster.contact_number__c); String strurl='http://xxyyyzzz.fdf&to='+FEMasterContact +'&text=Transaction+of+Rs.1234+made+&alert=1'; HttpRequest req=new HttpRequest(); req.setEndpoint(strurl); req.setMethod('POST'); string strbody='hi'; req.setBody(strbody); req.setCompressed(true); Http http=new Http(); HTTPResponse res=http.send(req); string strRes=res.getbody(); system.debug('**** Response is *****'+strRes); } }}
*************************************trigger******************************************************
TRigger LeadSmsTrg on lead(after Insert){list<Lead> lstLead;list<Lead> lstphnum = new list<Lead>();string PhoneNumber;string product;string officerName;list<string> lstFECode = new list<string>();list<FE_Master__c> lstFEMaster = new list<FE_Master__c>(); list<string> lstleadMobile = new list<string>();if(Trigger.IsAfter){ for(Lead objLead : [select id,FE_Code__c,Product__c,Mobile_Number__c from Lead where id In:trigger.New and Mobile_Number__c!=null ]){ product = string.valueof(objlead.product__C); officerName = string.valueof(objlead.FE_CODE__c); PhoneNumber = string.valueof(objlead.Mobile_Number__c); lstFECode.add(objLead.FE_Code__c); system.debug('***************8objLead.FE_Code__c'+objLead.FE_Code__c); SMSToLead.sendSMS(PhoneNumber,product,officerName,lstFECode); if(objLead.FE_Code__c!=null){ SMSToLead.sendSMSTOFEMaster(lstFECode); } } }
}
the issue is when the trigger is fired the class is called and this class need to be executed in batches...............
Any One can help
plsssssssssssss
thanx in Advance,
Ashy