You need to sign in to do that
Don't have an account?
Meena Sambath
de reference a null object
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==');
}
}
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==');
}
}
Try to put Limit 1 in your query and check the result if you are able to get the result also try same query in your query editor of developer console.
Best Regards,
Sandhya