You need to sign in to do that
Don't have an account?
MaheemSam
Before Delete thorws Attempt to de-reference a null object
Hi,
I am trying to implement a delete validation on opportunity object using a trigger but I keep getting Attempt to de-reference a null object error please suggest me what is the issue in this code.
Error is coming from line below
List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];
Please let me know if there are any other way to fix this issue.
Thanks
Sudhir
I am trying to implement a delete validation on opportunity object using a trigger but I keep getting Attempt to de-reference a null object error please suggest me what is the issue in this code.
public static void processOptyDelete(List<Opportunity> newLst){ List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()]; for(Opportunity opp: newLst){ for(SBQQ__Quote__c sqt : cpqqt){ if(opp.id == sqt.SBQQ__Opportunity2__c){ opp.addError('Opportunity have Quotes ,so you can not delete this opportunity'); } } } }
Error is coming from line below
List<SBQQ__Quote__c> cpqqt = [select id,SBQQ__Opportunity2__c from SBQQ__Quote__c where SBQQ__Opportunity2__c = :trigger.newmap.keyset()];
Please let me know if there are any other way to fix this issue.
Thanks
Sudhir
Try this:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Try the following code it works for you: I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
I dont want to use try catch because if there are any other error it will be difficult to debug.
Please let me know if there are any alternative methods
Thanks
Sudhir