You need to sign in to do that
Don't have an account?
Sathish Panjala 12
Argument must be an inline query
Hi ... As a part of create a Schedule Batch Apex a query will return list of deals...... But I could not able to handle the list of records in Execute method.
End up with " Argument must be an Inline query"
I have written the following code for this:
global class PaymentAmountDueUpdt implements Database.Batchable<sObject>{
global string [] email = new string[] {'xxxxxxxx.com'};
List<Deal__c> deals;
//Start method
global Database.QueryLocator start (Database.BatchableContext BC) {
//List<Deal__c> deals = [select id, Payment_Amount_Due__c,(select id, Payment_Date__c, Purchase_Amount__c from cash_flows__r where Payment_Satisfied__c = false order by Payment_Date__c limit 1) from deal__c ];
Deals = new List<Deal__c>([select id, Payment_Amount_Due__c,(select id, Payment_Date__c, Purchase_Amount__c from cash_flows__r where Payment_Satisfied__c = false order by Payment_Date__c limit 1) from deal__c]);
return Database.getQueryLocator(Deals);
}
//Execute Method
global void execute (Database.BatchableContext BC, List<Deal__c> deals) {
for(Deal__c d : deals){
if(!d.cash_flows__r.isEmpty()){
d.Payment_Amount_Due__c = d.cash_flows__r.get(0).Purchase_Amount__c;
}
}
update deals;
}
Please suggest me where it went wrong.
Thanks !
End up with " Argument must be an Inline query"
I have written the following code for this:
global class PaymentAmountDueUpdt implements Database.Batchable<sObject>{
global string [] email = new string[] {'xxxxxxxx.com'};
List<Deal__c> deals;
//Start method
global Database.QueryLocator start (Database.BatchableContext BC) {
//List<Deal__c> deals = [select id, Payment_Amount_Due__c,(select id, Payment_Date__c, Purchase_Amount__c from cash_flows__r where Payment_Satisfied__c = false order by Payment_Date__c limit 1) from deal__c ];
Deals = new List<Deal__c>([select id, Payment_Amount_Due__c,(select id, Payment_Date__c, Purchase_Amount__c from cash_flows__r where Payment_Satisfied__c = false order by Payment_Date__c limit 1) from deal__c]);
return Database.getQueryLocator(Deals);
}
//Execute Method
global void execute (Database.BatchableContext BC, List<Deal__c> deals) {
for(Deal__c d : deals){
if(!d.cash_flows__r.isEmpty()){
d.Payment_Amount_Due__c = d.cash_flows__r.get(0).Purchase_Amount__c;
}
}
update deals;
}
Please suggest me where it went wrong.
Thanks !
Database.getQueryLocator() takes in a string as a parameter. Deals is a list of Deal__c records. To resolve this you must replace the line 3 where you declare a list of Deal__c with the following
and populate it with the actual query string in order to pass it in to the getquerylocater call. Something like the following
Hope this helps!
AM
All Answers
Database.getQueryLocator() takes in a string as a parameter. Deals is a list of Deal__c records. To resolve this you must replace the line 3 where you declare a list of Deal__c with the following
and populate it with the actual query string in order to pass it in to the getquerylocater call. Something like the following
Hope this helps!
AM
1) http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html
NOTE:- you need to pass Query and Finish method.
Let us know if this will help you
Appreciated your help on this.
I actually have finish method as well on that class, But I didn't placed that part here.
Because am sure that the error is not related to that method.
Anyway thanks a lot for your quick responce and time.
Sincere appologies for the confusion caused.
Sathish