Skip to main content
Shekhar M Ramesh 님이 #Trailhead Challenges에 질문했습니다

Hi there, i have a batch class which updates a field(verification status- picklist)  on the custom object. Below is my batch class and i was testing if it would run from developer console but did not get any error nor the fields are updating. Please share your thoughts.

 

Thanks in advance

**************************************************************************************

Batch class:

**************************************************************************************

global class BackgroundCheck implements Database.Batchable<sObject>

{

   global Database.QueryLocator start (Database.BatchableContext bc)

    {

      string query = 'select id,LinkedIn_Profile__c from Trainer_Master__c';

      return Database.getQueryLocator(query);

    }

 

    global void execute (Database.BatchableContext bc , list<Trainer_Master__c> VarRec)

    {

      

      for(Trainer_Master__c VarR : VarRec)

      {

         if(VarR.LinkedIn_Profile__c == ' ')

           {

             VarR.Verification_Status__c = 'Details Needed'; 

           }

         else if(VarR.LinkedIn_Profile__c == 'Available' && VarR.Background_Check_Done__c == 'No')

           {

             VarR.Verification_Status__c = 'Non Verified'; 

           }

         else if(VarR.LinkedIn_Profile__c == 'Available' && VarR.Background_Check_Done__c == 'Yes')

           {

             VarR.Verification_Status__c = 'Verified';  

           }        

      }

         update VarRec;

    }

    global void finish (database.batchablecontext bc)

    {

    }

 

}

******************************************************************************************

Anonymous  window

******************************************************************************************

BackgroundCheck VarBC = new BackgroundCheck();

database.executebatch(VarBC);

답변 1개
  1. 2023년 9월 14일 오후 6:16

    Hi @Shekhar M Ramesh 

    1. You query Fields Carefully and Query Picklist Field "Verification Status" .

    2. You can add system. Debug statement to find your problems.

     

    Best Regards,

    Piyush 

0/9000