• Meena Sambath
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am getting null pointer exception exception        System.debug('Notes---->'+Notes);   Approval_Routing_Note__c (long text field ) has data i am unable to query it in code.


global class rou implements Database.Batchable<sObject>{
    global Integer recordsProcessed = 0;
    global Database.QueryLocator start(Database.BatchableContext bc) {
        
  String  records ='Select id,Approval_Matrix__C,Approval_Routing_Note__c from Approval__C where Approval_Matrix__C=null';
    
        return Database.getQueryLocator('Select id,Approval_Matrix__C,Approval_Routing_Note__c from Approval__C where Approval_Matrix__C=null');
            }
    global void execute(Database.BatchableContext bc, List<Approval__c> rec){
        System.debug(rec);
        set<id> R= new set<id>();
        Map<id,Approval__c> m = new Map<id, Approval__c>();
        List<Approval__C> mlist = new list <Approval__C>();
        for(Approval__c a: rec)
        {
           r.add(a.id);
        }
        system.debug('a-->'+R);
        List<Approval__C> record =new list<Approval__C>(); 
        record = [select id, Approval_Matrix__C, Approval_Routing_Note__c From Approval__c where id IN: R];
        
        system.debug('record-->'+record);
   String[] Results = new List<String>();
        
        for(Approval__C A : record){
         String  Notes = A.Approval_Routing_Note__c;
            System.debug('Notes---->'+Notes);
         for(String email : Notes.split(':')){
            Results.add(email);     
            }
string user = Results[1];
 system.debug(user);
String[] Result1 = new List<String>();
          for(String email1 : user.split('Approval Matrix Name')){
        Result1.add(email1); 
    }
String s1 = Result1[0];
String s2 = s1.replaceAll(',','');
string s3 = s2.substring(0,19);
system.debug(s3);
    id S = id.valueOf(s3);        
        A.Approval_Matrix__c = S;
     m.put(A.id,A );
            mlist.add(A);
        }
        
        update mlist;
    }
 global void finish(Database.BatchableContext bc)
    {
       System.debug(LoggingLevel.INFO, '==Batch Job Complete==');
    }
    }
  String  records ='Select id,Approval_Matrix__C,Approval_Routing_Note__c from Approval__C where Approval_Matrix__C=null';
I am able to query these fields Approval_Matrix__C( Ready Only)   , Approval_Routing_Note__c (Editable) in Query Editor these fields have some data but i am not able to query in in code.