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

how to write 2 queries in the start method of batch class based on condition
select id,name,email from Account where createddate=today
select accountid,Account.name from Contact where account.closeddate=today and createdate=today
select accountid,Account.name from Contact where account.closeddate=today and createdate=today
Crate a two differnet construtcors and first one for one query and second one for seconf query as show below
And You can excute it as
All Answers
Crate a two differnet construtcors and first one for one query and second one for seconf query as show below
And You can excute it as
thanks for quick reply..I tried no errors ,but its not giving me proper output...i dont know where am missing
refer ths links
https://help.salesforce.com/articleView?id=code_dev_console_checkpoints_setting.htm&type=5
but what if have differnt API names of our 2 queries..as we need to work with filed names here...
any clue?
so it is working for only query for me..
is it possible to get the api names of the Scope object of execute method dynamically?
so that based on condtition or based constructor it will pass those records to execute method, i use those api fileds dynamically?
I dint get what exactly you are saying...include all fileds in both the soql queries means?.....
I just want to implement it to scope object fileds that will come ...
both condtions we will get 2 different set of object records(2 scopes but synchronusly)...i want to work on those 2 scope object filed names...
any clues? correct me if my assumption is wrong
As you mentioned above,
// Second Query batch Id batchInstanceId = Database.executeBatch(new DemoBatch(), 5); // First Query batch Id batchInstanceId1= Database.executeBatch(new DemoBatch('select id,name,email from Account where createddate=today'), 5);
if i execute these 2 lines,
what would be the value of the Query...
what would be the scope records...are they related to query1/query2
could you kindly explain me
what would be the value of the Query...
The query will be based on how you are calling the batch by using the constructor
Id batchInstanceId = Database.executeBatch(new DemoBatch(), 5)===>> Query will be
Query='select accountid,Account.name from Contact where account.closeddate=today and createdate=today'
what would be the scope records...are they related to query1/query2
batchInstanceId1= Database.executeBatch(new DemoBatch('select id,name,email from Account where createddate=today'), 5)===> Query will be
'select id,name,email from Account where createddate=today')
Your scope will be the list of account which you query will be return and you are seeing the values to 5