You need to sign in to do that
Don't have an account?
records were not updated
Hi all,
At in batch apex coding, they want to update the records in Student__c custom sobject as like if student is male they can appear Mr infront of his name. If student is female they can appear Miss infront of her name
I tried this above code:
At in batch apex coding, they want to update the records in Student__c custom sobject as like if student is male they can appear Mr infront of his name. If student is female they can appear Miss infront of her name
I tried this above code:
public class apex_student implements database.batchable<sobject>{ integer count = 0; public database.querylocator start(database.batchableContext abc){ string myacc = 'SELECT Student_Id__c, Name, Gender__c FROM Student__c'; system.debug('start:::'); return database.getquerylocator(myacc); } public void execute(database.batchableContext abc, list<Student__c> acc){ count++; system.debug('Execute'+count); for(Student__c x:acc){ if(x.Gender__c == 'Male'){ x.Gender__c = 'Mr'; } if(x.Gender__c == 'Female'){ x.Gender__c = 'Miss'; update x; } } } public void finish(database.batchableContext abc){ system.debug('Finish:::'); } }But records in sobject was not updated, Please resolve my problem. Thank You !




Add a list to update record