• Sathish Panjala 12
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
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 !
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 !