You need to sign in to do that
Don't have an account?
Iqra Tech
how can i convert my HTTP Callout class into the Batch class
I am having Http callout class to post the data in third party class is working perfctly according to my requirement , but the thing as i am new on Devlopment so i need to convert this class into the batch class how can i convert this can any please help me i am just stuck on this.........
All Answers
Please make sure you are implementing Database.AllowsCallouts interface in your batch class.
Remember you cannot call the @future method from batch class.
can you look into that and make batch class it will be helpful for me as in my class insert method are used so i am unable to convert into the batch class can you please ..........
public class NEW_API_CLASSES {
Public static void Insert_Records()
{
List<Floor_Plan_Mapping__c> LstFlrmapping=new list< Floor_Plan_Mapping__c>();
LstFlrmapping=[select Id,Edition__c,Object__c,Opportunity__c,Opportunity_Id__c,Stage__c,Banner_Name__c,Stand_no__c,Edition_Event_Name__c,Additional_field_3__c,
Additional_field_2__c,Type_of_Stand__c,Customer_Product__c,Additional_field_4__c,Additional_field_1__c,Contractual_Sq_M__c,Hall__c,Height__c,Width__c,
Open_Sides__c,Additional_field_6__c,Additional_field_5__c,Phone__c,Website__c,Fax__c,PO_Box__c,Floor_Plan_Stage__c from Floor_Plan_Mapping__c order by createdDate DESC limit 1];
String query= 'select ID,' ;
if(LstFlrmapping[0].Edition__c!=null){
query += LstFlrmapping[0].Edition__c+',' ;
}
if(LstFlrmapping[0].Opportunity__c!=null){
query += LstFlrmapping[0].Opportunity__c+',' ;
}
if(LstFlrmapping[0].Opportunity_Id__c!=null){
query += LstFlrmapping[0].Opportunity_Id__c+',' ;
}
if(LstFlrmapping[0].Stage__c!=null){
query += LstFlrmapping[0].Stage__c+',' ;
}
if(LstFlrmapping[0].Banner_Name__c!=null){
query += LstFlrmapping[0].Banner_Name__c+',' ;
}
if(LstFlrmapping[0].Stand_no__c!=null){
query += LstFlrmapping[0].Stand_no__c+',' ;
}
if(LstFlrmapping[0].Additional_field_3__c!=null){
query += LstFlrmapping[0].Additional_field_3__c+',' ;
}
if(LstFlrmapping[0].Additional_field_2__c!=null){
query += LstFlrmapping[0].Additional_field_2__c+',' ;
}
if(LstFlrmapping[0].Type_of_Stand__c!=null){
query += LstFlrmapping[0].Type_of_Stand__c+',' ;
}
if(LstFlrmapping[0].Customer_Product__c!=null){
query += LstFlrmapping[0].Customer_Product__c+',' ;
}
if(LstFlrmapping[0].Additional_field_4__c!=null){
query += LstFlrmapping[0].Additional_field_4__c+',' ;
}
if(LstFlrmapping[0].Additional_field_1__c!=null){
query += LstFlrmapping[0].Additional_field_1__c+',' ;
}
if(LstFlrmapping[0].Contractual_Sq_M__c!=null){
query += LstFlrmapping[0].Contractual_Sq_M__c+',' ;
}
if(LstFlrmapping[0].Hall__c!=null){
query += LstFlrmapping[0].Hall__c+',' ;
}
if(LstFlrmapping[0].Height__c!=null){
query += LstFlrmapping[0].Height__c+',' ;
}
if(LstFlrmapping[0].Width__c!=null){
query += LstFlrmapping[0].Width__c+',' ;
}
if(LstFlrmapping[0].Open_Sides__c!=null){
query += LstFlrmapping[0].Open_Sides__c+',' ;
}
if(LstFlrmapping[0].Additional_field_6__c!=null){
query += LstFlrmapping[0].Additional_field_6__c+',' ;
}
if(LstFlrmapping[0].Additional_field_5__c!=null){
query += LstFlrmapping[0].Additional_field_5__c+',' ;
}
if(LstFlrmapping[0].Phone__c!=null){
query += LstFlrmapping[0].Phone__c+',' ;
}
if(LstFlrmapping[0].Website__c!=null){
query += LstFlrmapping[0].Website__c+',' ;
}
if(LstFlrmapping[0].Fax__c!=null){
query += LstFlrmapping[0].Fax__c+',' ;
}
if(LstFlrmapping[0].PO_Box__c!=null){
query += LstFlrmapping[0].PO_Box__c+',' ;
}
if(LstFlrmapping[0].Floor_Plan_Stage__c!=null){
query += LstFlrmapping[0].Floor_Plan_Stage__c+',' ;
}
query = query.removeEnd(',');
query += ' from '+LstFlrmapping[0].Object__c+' where '+LstFlrmapping[0].Edition__c+' = \''+LstFlrmapping[0].Edition_Event_Name__c +'\'';
String Edition=LstFlrmapping[0].Edition__c;
String Opportunity=LstFlrmapping[0].Opportunity__c;
String OpprtunityId=LstFlrmapping[0].Opportunity_Id__c;
String Objects=LstFlrmapping[0].Object__c;
String stage=LstFlrmapping[0].Stage__c;
String BannerName=LstFlrmapping[0].Banner_Name__c;
String StandNo=LstFlrmapping[0].Stand_no__c;
String Edition_ID=LstFlrmapping[0].Additional_field_3__c;
String Stand_Sub_Allocation_Name=LstFlrmapping[0].Additional_field_2__c;
String Type_of_Stand=LstFlrmapping[0].Type_of_Stand__c;
String Customer_Product=LstFlrmapping[0].Customer_Product__c;
String Customer_Product_category=LstFlrmapping[0].Additional_field_4__c;
String Product_Sub_Category=LstFlrmapping[0].Additional_field_1__c;
String Contractual_Sq_M=LstFlrmapping[0].Contractual_Sq_M__c;
String Hall=LstFlrmapping[0].Hall__c;
String Height=LstFlrmapping[0].Height__c;
String Width=LstFlrmapping[0].Width__c;
String Open_Sides=LstFlrmapping[0].Open_Sides__c;
String Street=LstFlrmapping[0].Additional_field_6__c;
String City=LstFlrmapping[0].Additional_field_5__c;
String Phone=LstFlrmapping[0].Phone__c;
String Web_Sites=LstFlrmapping[0].Website__c;
String Fax=LstFlrmapping[0].Fax__c;
String PO_BOX=LstFlrmapping[0].PO_Box__c;
String Floor_Plan_Stage = LstFlrmapping[0].Floor_Plan_Stage__c;
System.debug('Query formed----> '+query);
List<sObject> sc= Database.query(query);
//System.debug('All Records -->'+sc);
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(sObject s : sc)
{
system.debug('Cheking Object ssss ---->'+s);
//OpportunityLineItem o = (OpportunityLineItem)s ;
//sObject o = (sObject)s.get(LstFlrmapping[0].Object__c);
//sObject o = ((LstFlrmapping[0].Object__c != null) ? (Sobject)s.get(LstFlrmapping[0].Object__c) : null);
sObject o = (sObject)s;
system.debug('Cheking Object---->'+o);
try
{
//OppWrapper oppwrappervar=new OppWrapper(o.P_Edition__c,o.P_Opportunity_ID__c,o.p_Opprotuny_name__c,o.P_Stage__c,o.Stand_Number_s__c,o.P_Banner__c);
OppWrapper oppwrappervars = new OppWrapper(
(LstFlrmapping[0].Edition__c != null) ? (string)o.get(LstFlrmapping[0].Edition__c) : null,
(LstFlrmapping[0].Opportunity_Id__c != null) ? (string)o.get(LstFlrmapping[0].Opportunity_Id__c) : null,
(LstFlrmapping[0].Opportunity__c != null) ? (string)o.get(LstFlrmapping[0].Opportunity__c) : null,
(LstFlrmapping[0].Stage__c != null) ? (string)o.get(LstFlrmapping[0].Stage__c) : null,
(LstFlrmapping[0].Banner_Name__c != null) ? (string)o.get(LstFlrmapping[0].Banner_Name__c) : null,
(LstFlrmapping[0].Stand_no__c != null) ? (string)o.get(LstFlrmapping[0].Stand_no__c) : null,
(LstFlrmapping[0].Additional_field_3__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_3__c) : null,
(LstFlrmapping[0].Additional_field_2__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_2__c) : null,
(LstFlrmapping[0].Phone__c != null) ? (string)o.get(LstFlrmapping[0].Phone__c) : null,
(LstFlrmapping[0].Website__c != null) ? (string)o.get(LstFlrmapping[0].Website__c) : null,
(LstFlrmapping[0].Additional_field_5__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_5__c) : null,
(LstFlrmapping[0].Additional_field_6__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_6__c) : null,
(LstFlrmapping[0].PO_Box__c != null) ? (string)o.get(LstFlrmapping[0].PO_Box__c) : null,
(LstFlrmapping[0].Customer_Product__c != null) ? (string)o.get(LstFlrmapping[0].Customer_Product__c) : null,
(LstFlrmapping[0].Additional_field_4__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_4__c) : null,
(LstFlrmapping[0].Fax__c != null) ? (string)o.get(LstFlrmapping[0].Fax__c) : null,
(LstFlrmapping[0].Additional_field_1__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_1__c) : null,
(LstFlrmapping[0].Hall__c != null) ? (string)o.get(LstFlrmapping[0].Hall__c) : null,
(LstFlrmapping[0].Height__c != null) ? (string)o.get(LstFlrmapping[0].Height__c) : null,
(LstFlrmapping[0].Width__c != null) ? (string)o.get(LstFlrmapping[0].Width__c) : null,
(LstFlrmapping[0].Contractual_Sq_M__c != null) ? (Decimal)o.get(LstFlrmapping[0].Contractual_Sq_M__c) : null,
(LstFlrmapping[0].Open_Sides__c != null) ? (string)o.get(LstFlrmapping[0].Open_Sides__c) : null,
(LstFlrmapping[0].Type_of_Stand__c != null) ? (string)o.get(LstFlrmapping[0].Type_of_Stand__c) : null);
oppWrapperVarList.add(oppwrappervars);
}catch(Exception ex)
{
System.debug('================'+ex.getMessage()+'======================'+ex);
}
}
string jsonbody=Json.serialize(oppWrapperVarList);
system.debug('Cheking API---->'+oppWrapperVarList);
system.debug('Json body---->'+jsonbody);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setTimeout(25000);
//request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
request.setEndpoint('http://sfdata.iqratechnology.com/api/data');
request.setMethod('POST');
request.setHeader('Content-Type','application/json');
request.setBody(jsonbody);
HttpResponse response = http.send(request);
system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
}
public class OppWrapper
{
public String EventName {get;set;}
public String RecordId {get;set;}
public String RecordName {get;set;}
public String RecordStage {get;set;}
public String StandNo {get;set;}
public String BannerName {get;set;}
public String Edition_ID {get;set;}
public String Stand_Sub_Allocation_Name {get;set;}
public String Phone {get;set;}
public String Web_Site {get;set;}
public String City {get;set;}
public String Street {get;set;}
public String PO_BOX {get;set;}
public String Customer_Product {get;set;}
public String Customer_Product_category {get;set;}
public String Fax {get;set;}
public String Product_Sub_Category {get;set;}
public String Hall {get;set;}
public String Height {get;set;}
public String Width {get;set;}
public Decimal Contractual_Sq_M {get;set;}
public String Open_Sides {get;set;}
public String Type_of_Stand {get;set;}
public OppWrapper(String EventName,String RecordId,String RecordName,String RecordStage,String BannerName,String StandNo,String Edition_ID,
String Stand_Sub_Allocation_Name,String Phone,String Web_Site,String City,String Street,String PO_BOX,String Customer_Product,
String Customer_Product_category,String Fax,String Product_Sub_Category,String Hall,String Height,String Width,Decimal Contractual_Sq_M,
String Open_Sides,String Type_of_Stand)
{
this.EventName =EventName;
this.RecordId =RecordId;
this.RecordName =RecordName;
this.RecordStage=RecordStage;
this.StandNo=StandNo;
this.BannerName=BannerName;
this.Edition_ID=Edition_ID;
this.Stand_Sub_Allocation_Name=Stand_Sub_Allocation_Name;
this.Phone=Phone;
this.Web_Site=Web_Site;
this.City=City;
this.Street=Street;
this.PO_BOX=PO_BOX;
this.Customer_Product=Customer_Product;
this.Customer_Product_category=Customer_Product_category;
this.Fax=Fax;
this.Product_Sub_Category=Product_Sub_Category;
this.Hall=Hall;
this.Height=Height;
this.Width=Width;
this.Contractual_Sq_M=Contractual_Sq_M;
this.Open_Sides=Open_Sides;
this.Type_of_Stand=Type_of_Stand;
}
}
}
Here is my try
1.MyBatchClass.apxc
2.NEW_API_CLASSES .apxc
3.Run the batch like this
4.NEW_API_CLASSES.Insert_Records method call for non-batch class
You can do that too. But it's a best practice to have a different class for callouts. You can reuse it in the future when your requirement changes.
global class Batch_API_New implements Database.Batchable<sObject>, Database.AllowsCallouts{
public Database.QueryLocator start(Database.BatchableContext bc) {
List<Floor_Plan_Mapping__c> LstFlrmapping=new list< Floor_Plan_Mapping__c>();
LstFlrmapping=[select Id,Edition__c,Object__c,Opportunity__c,Opportunity_Id__c,Stage__c,Banner_Name__c,Stand_no__c,Edition_Event_Name__c,Additional_field_3__c,
Additional_field_2__c,Type_of_Stand__c,Customer_Product__c,Additional_field_4__c,Additional_field_1__c,Contractual_Sq_M__c,Hall__c,Height__c,Width__c,
Open_Sides__c,Additional_field_6__c,Additional_field_5__c,Phone__c,Website__c,Fax__c,PO_Box__c,Floor_Plan_Stage__c from Floor_Plan_Mapping__c order by createdDate DESC limit 1];
String query= 'select ID,' ;
if(LstFlrmapping[0].Edition__c!=null){
query += LstFlrmapping[0].Edition__c+',' ;
}
if(LstFlrmapping[0].Opportunity__c!=null){
query += LstFlrmapping[0].Opportunity__c+',' ;
}
if(LstFlrmapping[0].Opportunity_Id__c!=null){
query += LstFlrmapping[0].Opportunity_Id__c+',' ;
}
if(LstFlrmapping[0].Stage__c!=null){
query += LstFlrmapping[0].Stage__c+',' ;
}
if(LstFlrmapping[0].Banner_Name__c!=null){
query += LstFlrmapping[0].Banner_Name__c+',' ;
}
if(LstFlrmapping[0].Stand_no__c!=null){
query += LstFlrmapping[0].Stand_no__c+',' ;
}
if(LstFlrmapping[0].Additional_field_3__c!=null){
query += LstFlrmapping[0].Additional_field_3__c+',' ;
}
if(LstFlrmapping[0].Additional_field_2__c!=null){
query += LstFlrmapping[0].Additional_field_2__c+',' ;
}
if(LstFlrmapping[0].Type_of_Stand__c!=null){
query += LstFlrmapping[0].Type_of_Stand__c+',' ;
}
if(LstFlrmapping[0].Customer_Product__c!=null){
query += LstFlrmapping[0].Customer_Product__c+',' ;
}
if(LstFlrmapping[0].Additional_field_4__c!=null){
query += LstFlrmapping[0].Additional_field_4__c+',' ;
}
if(LstFlrmapping[0].Additional_field_1__c!=null){
query += LstFlrmapping[0].Additional_field_1__c+',' ;
}
if(LstFlrmapping[0].Contractual_Sq_M__c!=null){
query += LstFlrmapping[0].Contractual_Sq_M__c+',' ;
}
if(LstFlrmapping[0].Hall__c!=null){
query += LstFlrmapping[0].Hall__c+',' ;
}
if(LstFlrmapping[0].Height__c!=null){
query += LstFlrmapping[0].Height__c+',' ;
}
if(LstFlrmapping[0].Width__c!=null){
query += LstFlrmapping[0].Width__c+',' ;
}
if(LstFlrmapping[0].Open_Sides__c!=null){
query += LstFlrmapping[0].Open_Sides__c+',' ;
}
if(LstFlrmapping[0].Additional_field_6__c!=null){
query += LstFlrmapping[0].Additional_field_6__c+',' ;
}
if(LstFlrmapping[0].Additional_field_5__c!=null){
query += LstFlrmapping[0].Additional_field_5__c+',' ;
}
if(LstFlrmapping[0].Phone__c!=null){
query += LstFlrmapping[0].Phone__c+',' ;
}
if(LstFlrmapping[0].Website__c!=null){
query += LstFlrmapping[0].Website__c+',' ;
}
if(LstFlrmapping[0].Fax__c!=null){
query += LstFlrmapping[0].Fax__c+',' ;
}
if(LstFlrmapping[0].PO_Box__c!=null){
query += LstFlrmapping[0].PO_Box__c+',' ;
}
if(LstFlrmapping[0].Floor_Plan_Stage__c!=null){
query += LstFlrmapping[0].Floor_Plan_Stage__c+',' ;
}
query = query.removeEnd(',');
query += ' from '+LstFlrmapping[0].Object__c+' where '+LstFlrmapping[0].Edition__c+' = \''+LstFlrmapping[0].Edition_Event_Name__c +'\'';
return Database.getQueryLocator(query);
String Edition=LstFlrmapping[0].Edition__c;
String Opportunity=LstFlrmapping[0].Opportunity__c;
String OpprtunityId=LstFlrmapping[0].Opportunity_Id__c;
String Objects=LstFlrmapping[0].Object__c;
String stage=LstFlrmapping[0].Stage__c;
String BannerName=LstFlrmapping[0].Banner_Name__c;
String StandNo=LstFlrmapping[0].Stand_no__c;
String Edition_ID=LstFlrmapping[0].Additional_field_3__c;
String Stand_Sub_Allocation_Name=LstFlrmapping[0].Additional_field_2__c;
String Type_of_Stand=LstFlrmapping[0].Type_of_Stand__c;
String Customer_Product=LstFlrmapping[0].Customer_Product__c;
String Customer_Product_category=LstFlrmapping[0].Additional_field_4__c;
String Product_Sub_Category=LstFlrmapping[0].Additional_field_1__c;
String Contractual_Sq_M=LstFlrmapping[0].Contractual_Sq_M__c;
String Hall=LstFlrmapping[0].Hall__c;
String Height=LstFlrmapping[0].Height__c;
String Width=LstFlrmapping[0].Width__c;
String Open_Sides=LstFlrmapping[0].Open_Sides__c;
String Street=LstFlrmapping[0].Additional_field_6__c;
String City=LstFlrmapping[0].Additional_field_5__c;
String Phone=LstFlrmapping[0].Phone__c;
String Web_Sites=LstFlrmapping[0].Website__c;
String Fax=LstFlrmapping[0].Fax__c;
String PO_BOX=LstFlrmapping[0].PO_Box__c;
String Floor_Plan_Stage = LstFlrmapping[0].Floor_Plan_Stage__c;
System.debug('Query formed----> '+query);
}
global void execute(Database.BatchableContext bc, List<sObject> sc){
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(sObject s : sc)
{
system.debug('Cheking Object ssss ---->'+s);
//OpportunityLineItem o = (OpportunityLineItem)s ;
//sObject o = (sObject)s.get(LstFlrmapping[0].Object__c);
//sObject o = ((LstFlrmapping[0].Object__c != null) ? (Sobject)s.get(LstFlrmapping[0].Object__c) : null);
sObject o = (sObject)s;
system.debug('Cheking Object---->'+o);
try
{
//OppWrapper oppwrappervar=new OppWrapper(o.P_Edition__c,o.P_Opportunity_ID__c,o.p_Opprotuny_name__c,o.P_Stage__c,o.Stand_Number_s__c,o.P_Banner__c);
OppWrapper oppwrappervars = new OppWrapper(
(LstFlrmapping[0].Edition__c != null) ? (string)o.get(LstFlrmapping[0].Edition__c) : null,
(LstFlrmapping[0].Opportunity_Id__c != null) ? (string)o.get(LstFlrmapping[0].Opportunity_Id__c) : null,
(LstFlrmapping[0].Opportunity__c != null) ? (string)o.get(LstFlrmapping[0].Opportunity__c) : null,
(LstFlrmapping[0].Stage__c != null) ? (string)o.get(LstFlrmapping[0].Stage__c) : null,
(LstFlrmapping[0].Banner_Name__c != null) ? (string)o.get(LstFlrmapping[0].Banner_Name__c) : null,
(LstFlrmapping[0].Stand_no__c != null) ? (string)o.get(LstFlrmapping[0].Stand_no__c) : null,
(LstFlrmapping[0].Additional_field_3__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_3__c) : null,
(LstFlrmapping[0].Additional_field_2__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_2__c) : null,
(LstFlrmapping[0].Phone__c != null) ? (string)o.get(LstFlrmapping[0].Phone__c) : null,
(LstFlrmapping[0].Website__c != null) ? (string)o.get(LstFlrmapping[0].Website__c) : null,
(LstFlrmapping[0].Additional_field_5__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_5__c) : null,
(LstFlrmapping[0].Additional_field_6__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_6__c) : null,
(LstFlrmapping[0].PO_Box__c != null) ? (string)o.get(LstFlrmapping[0].PO_Box__c) : null,
(LstFlrmapping[0].Customer_Product__c != null) ? (string)o.get(LstFlrmapping[0].Customer_Product__c) : null,
(LstFlrmapping[0].Additional_field_4__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_4__c) : null,
(LstFlrmapping[0].Fax__c != null) ? (string)o.get(LstFlrmapping[0].Fax__c) : null,
(LstFlrmapping[0].Additional_field_1__c != null) ? (string)o.get(LstFlrmapping[0].Additional_field_1__c) : null,
(LstFlrmapping[0].Hall__c != null) ? (string)o.get(LstFlrmapping[0].Hall__c) : null,
(LstFlrmapping[0].Height__c != null) ? (string)o.get(LstFlrmapping[0].Height__c) : null,
(LstFlrmapping[0].Width__c != null) ? (string)o.get(LstFlrmapping[0].Width__c) : null,
(LstFlrmapping[0].Contractual_Sq_M__c != null) ? (Decimal)o.get(LstFlrmapping[0].Contractual_Sq_M__c) : null,
(LstFlrmapping[0].Open_Sides__c != null) ? (string)o.get(LstFlrmapping[0].Open_Sides__c) : null,
(LstFlrmapping[0].Type_of_Stand__c != null) ? (string)o.get(LstFlrmapping[0].Type_of_Stand__c) : null);
oppWrapperVarList.add(oppwrappervars);
}catch(Exception ex)
{
System.debug('================'+ex.getMessage()+'======================'+ex);
}
}
string jsonbody=Json.serialize(oppWrapperVarList);
system.debug('Cheking API---->'+oppWrapperVarList);
system.debug('Json body---->'+jsonbody);
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setTimeout(25000);
//request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
request.setEndpoint('http://sfdata.iqratechnology.com/api/data');
request.setMethod('POST');
request.setHeader('Content-Type','application/json');
request.setBody(jsonbody);
HttpResponse response = http.send(request);
system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
System.debug('The status code returned was not expected: ' +
response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
}
public class OppWrapper
{
public String EventName {get;set;}
public String RecordId {get;set;}
public String RecordName {get;set;}
public String RecordStage {get;set;}
public String StandNo {get;set;}
public String BannerName {get;set;}
public String Edition_ID {get;set;}
public String Stand_Sub_Allocation_Name {get;set;}
public String Phone {get;set;}
public String Web_Site {get;set;}
public String City {get;set;}
public String Street {get;set;}
public String PO_BOX {get;set;}
public String Customer_Product {get;set;}
public String Customer_Product_category {get;set;}
public String Fax {get;set;}
public String Product_Sub_Category {get;set;}
public String Hall {get;set;}
public String Height {get;set;}
public String Width {get;set;}
public Decimal Contractual_Sq_M {get;set;}
public String Open_Sides {get;set;}
public String Type_of_Stand {get;set;}
public OppWrapper(String EventName,String RecordId,String RecordName,String RecordStage,String BannerName,String StandNo,String Edition_ID,
String Stand_Sub_Allocation_Name,String Phone,String Web_Site,String City,String Street,String PO_BOX,String Customer_Product,
String Customer_Product_category,String Fax,String Product_Sub_Category,String Hall,String Height,String Width,Decimal Contractual_Sq_M,
String Open_Sides,String Type_of_Stand)
{
this.EventName =EventName;
this.RecordId =RecordId;
this.RecordName =RecordName;
this.RecordStage=RecordStage;
this.StandNo=StandNo;
this.BannerName=BannerName;
this.Edition_ID=Edition_ID;
this.Stand_Sub_Allocation_Name=Stand_Sub_Allocation_Name;
this.Phone=Phone;
this.Web_Site=Web_Site;
this.City=City;
this.Street=Street;
this.PO_BOX=PO_BOX;
this.Customer_Product=Customer_Product;
this.Customer_Product_category=Customer_Product_category;
this.Fax=Fax;
this.Product_Sub_Category=Product_Sub_Category;
this.Hall=Hall;
this.Height=Height;
this.Width=Width;
this.Contractual_Sq_M=Contractual_Sq_M;
this.Open_Sides=Open_Sides;
this.Type_of_Stand=Type_of_Stand;
}
}
}
global void finish(Database.BatchableContext bc){
Id job= bc.getJobId();
System.debug(job);
}
}
it is working perfctly just need to do more testting on that then after need to add authentication and need to do shedlue on futurer your help needed can i get you email id if i needed your help to achive this requiremnt...
'select Id,Edition__c,Object__c,Opportunity__c,Opportunity_Id__c,Stage__c,Banner_Name__c,Stand_no__c,Edition_Event_Name__c,Additional_field_3__c,' +
'Additional_field_2__c,Type_of_Stand__c,Customer_Product__c,Additional_field_4__c,Additional_field_1__c,Contractual_Sq_M__c,Hall__c,Height__c,Width__c,' +
'Open_Sides__c,Additional_field_6__c,Additional_field_5__c,Phone__c,Website__c,Fax__c,PO_Box__c,Floor_Plan_Stage__c from ' +
//'Floor_Plan_Mapping__c order by createdDate DESC limit 1'
'Floor_Plan_Mapping__c where Edition_Event_Name__c =:'FM Expo 2017'');
i am getting errors when i am adding where condition in that please correct ........
Replace your last line with this 'Floor_Plan_Mapping__c where Edition_Event_Name__c =\'FM Expo 2017\'');
sir if i have more than one value like FM Expo 2017 and FM Expo 2018 how to write for calling those in where condtion?
'Floor_Plan_Mapping__c where Edition_Event_Name__c =\'FM Expo 2017\' ,'FM Expo 2018''); i tried this but not working can u please chehk this ...
Add your where conditions in a list before return.
Change the last line of the query
Like suppose i am passing two values in myrecord like this FM Expo 2017, FM Expo 2018, then how can we call in our query?
@Rajesh_Kumar Sir
Like this we are using in vf page to store the muliple or single values in wheere condtion dynamically can u please chehk this i am stuck to add thiss logic can you please chehk this and provide me a solution
WHERE '+fldAPINameMap.get(selectedField)+' IN (\'' + String.join( criteria.split( ',' ), '\',\'' ) +'\') limit 999 ';
15:56:56.0 (169021698)|HEAP_ALLOCATE|[203]|Bytes:234
15:56:56.0 (169029968)|VARIABLE_SCOPE_BEGIN|[203]|queryStr1|String|false|false
15:56:56.0 (169048259)|VARIABLE_ASSIGNMENT|[203]|queryStr1|"SELECT createdDate,l (214 more) ..."
15:56:56.0 (169058985)|STATEMENT_EXECUTE|[204]
15:56:56.0 (169062509)|HEAP_ALLOCATE|[204]|Bytes:11
15:56:56.0 (169070573)|HEAP_ALLOCATE|[204]|Bytes:245
15:56:56.0 (169105832)|USER_DEBUG|[204]|DEBUG|queryStr1-=SELECT createdDate,lastModifiedDate,P_Opportunity_ID__c,p_Opprotuny_name__c,P_Stage__c,P_Banner__c,Stand_Number_s__c,Edition_id__c,P_Edition__c FROM opportunitylineitem WHERE P_Edition__c IN ('FM Expo 2017','FM Expo 2018') limit 999
15:56:56.0 (169124659)|STATEMENT_EXECUTE|[205]
Please chehk this
WHERE '+fldAPINameMap.get(selectedField)+' IN :criteria.split( ',' ) limit 999 ';
List<String> nameList = nameStr.split(',');
System.debug(Database.query('SELECT Id, Name FROM Account WHERE Name IN :nameList'));
yes but what if String nameStr = 'Test,Rajesh'; insted of String nameStr = 'xyz,pqr'; came that why need to dynamically can it be possible??
Edition_Event_Name__c stroing our values like FM Expo 2017 this or FM Expo 2017,FM Expo 2018 tahts why we need to do dynamically i am unble to understand how to do that can you write that one...