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

SOQL query with map passed over to batch
I have a class that does some work but at the end it needs to call the batch apex and pass a query the problem I am having is I want the query to be only where id in MyMap. For example
Database.executeBatch(new JsonMassImportBatch('Select id, Name from Contract where id in : ' (Map in the batch class with the ids keyset should be here),'Contract',new JsonMassImportBatch.CustomObj(holdLease,new List<String>{'Current_Rental_Rate__c','Renewal_Date__c'},holdDate)));
The end is me passing in the map for the batch call to use ie holdlease
How should i format the batch side to make this work?
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query + LeaseMap.keySet());
}
Database.executeBatch(new JsonMassImportBatch('Select id, Name from Contract where id in : ' (Map in the batch class with the ids keyset should be here),'Contract',new JsonMassImportBatch.CustomObj(holdLease,new List<String>{'Current_Rental_Rate__c','Renewal_Date__c'},holdDate)));
The end is me passing in the map for the batch call to use ie holdlease
How should i format the batch side to make this work?
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query + LeaseMap.keySet());
}
See this class Method runJobForParticularRecords is runs a batch for particualr records in the Map.
i hope this will solve your issue.
Thanks
Shashikant
All Answers
Following code piece can help you in attaching query and the keyset of the map variable.
Remember to remove : from your existing query.
Let me know if this helps.
See this class Method runJobForParticularRecords is runs a batch for particualr records in the Map.
i hope this will solve your issue.
Thanks
Shashikant