You need to sign in to do that
Don't have an account?
Swaroopa Akula 10
getting an error message-System.NullPointerException: Attempt to de-reference a null object
we have a requirement that when if a Conga transaction record has 'Sent' status , it should not allow the user to create a new conga transaction record. I created a trigger and apex handler class.
trigger congatransaction on APXT_CongaSign__Transaction__c (before INSERT) {
congatransactionHandler.congatransactionMethod(Trigger.NewMap,Trigger.OldMap);
}
public class congatransactionHandler {
public static void congatransactionMethod(Map<Id,APXT_CongaSign__Transaction__c> newconMap, Map<Id,APXT_CongaSign__Transaction__c> oldconMap){
Set<Id> conIds = New Set<Id>();
List<APXT_CongaSign__Transaction__c> conList = New List<APXT_CongaSign__Transaction__c>();
for(APXT_CongaSign__Transaction__c con : newconMap.values()){
APXT_CongaSign__Transaction__c oldcontranmap = oldconMap.get(con.Id);
if(oldconMap!=null && oldconMap.size()>0)
// Trigger.new records are conveniently the "new" versions!
{ //Boolean oldcontransactionmap = oldcontranmap.APXT_CongaSign__Status__c.equals('SENT');
if((newconMap.get(con.Id).Parent_a29__c== oldcontranmap.Parent_a29__c) && oldcontranmap.APXT_CongaSign__Status__c.equals('SENT')){
con.adderror('You have already sent the conga transaction');
}
}
}
}
}
trigger congatransaction on APXT_CongaSign__Transaction__c (before INSERT) {
congatransactionHandler.congatransactionMethod(Trigger.NewMap,Trigger.OldMap);
}
public class congatransactionHandler {
public static void congatransactionMethod(Map<Id,APXT_CongaSign__Transaction__c> newconMap, Map<Id,APXT_CongaSign__Transaction__c> oldconMap){
Set<Id> conIds = New Set<Id>();
List<APXT_CongaSign__Transaction__c> conList = New List<APXT_CongaSign__Transaction__c>();
for(APXT_CongaSign__Transaction__c con : newconMap.values()){
APXT_CongaSign__Transaction__c oldcontranmap = oldconMap.get(con.Id);
if(oldconMap!=null && oldconMap.size()>0)
// Trigger.new records are conveniently the "new" versions!
{ //Boolean oldcontransactionmap = oldcontranmap.APXT_CongaSign__Status__c.equals('SENT');
if((newconMap.get(con.Id).Parent_a29__c== oldcontranmap.Parent_a29__c) && oldcontranmap.APXT_CongaSign__Status__c.equals('SENT')){
con.adderror('You have already sent the conga transaction');
}
}
}
}
}
Please see if the below code help you., I just placed necessary checks to avoid null pointer
All Answers
Please see if the below code help you., I just placed necessary checks to avoid null pointer
try with below trigger code.
If this helps, Please mark it as best answer.
Thanks!!