Skip to main content
Trying to update Month and Year from this object obj_a__c.  I am getting error. 

 

"Compile Error: Initial term of field expression must be a concrete SObject: LIST<obj_a__c>"

 

Code:

 

public void perod()

 

{

 

List<obj_a__c> clo=[select id,Month__c,Year__c,Country__c from obj_a__c where Country__c='America'];

 

Integer yr=Integer.ValueOf(clo.Year__c);

 

Integer mn=Integer.ValueOf(clo.Month__c);

 

for(obj_a__c copy: clo)

 

{

 

if(mn==12)

 

{

 

yr++;

 

mn=1;

 

}

 

else

 

{

 

mn++;

 

}

 

update clo;

 

}

 

}
5 respuestas
  1. 7 ene 2014, 06:01
    Hey Vivekh,

     

    Try replacing update clo; with this:

     

    clo.Year__c = String.valueOf(yr);

     

    clo.Month__c = String.valueOf(mn);

     

    update clo;

     

    yr and mn are separate from clo, so clo's fields don't get updated unless you join them together again at the end  =)

     

    David
0/9000