0

I am getting subject error with below code. The line number is on update statement conditional if clause. But I can't get why I am getting such error? I have a trigger validation for those Call2_vod__c records whose Status field value is Submitted_vod. So I try to deal with only those records for whom I have set ESR_CALL__C field value as true in current run. Can someone help please? Please let me know if you need further info

Class:

global class AckCallUpdatenew implements Database.Batchable { global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'SELECT Id,Name,Account_vod__c,Call_Date_vod__c,ESR_Call__c,Unlock_vod__c FROM Call2_vod__c where ESR_Call__c=null and Recordtype.Name like \'%Sample%\' and Status_vod__c = \'Submitted_vod\''; return Database.getQueryLocator(query); }

global void execute(Database.BatchableContext BC, List<Call2_vod__c> scope) {

List<Call2_vod__c> AckCall= 
        [SELECT  Ack_For_Call_abv__c  
                  FROM Call2_vod__c
                 where  recordtype.Name like '%Acknowledge%'];

// Set resultIds = (new Map(AckCall)).keySet();
Set s1 = new Set();

  for(Call2_Vod__c record:AckCall) {
            s1.add(record.Ack_For_Call_abv__c);
            }           
     for(Call2_vod__c a : scope)
     {
       If(!s1.contains(a.Name))
       {
              if(a.ESR_Call__c==false && a.Call_Date_vod__c+90<date.today())
               {
                a.Unlock_vod__c=true;
                a.ESR_Call__c=true;
               // a.Status_vod__c='Saved_vod';


                }


       }

       else continue;

                 //Date d=a.Call_Date_vod__c+90;



     }

        if(scope.ESR_Call__c==true)
        {
        update scope;
        }
}   

global void finish(Database.BatchableContext BC) {
}

}

1 Answer 1

2

Data type of scope is list and you are trying to access field of record without any index.

Something like this should work Scope[0].fieldname__c

You will need to provide correct index as per logic. I have used 0 just to explain.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .