0

I need to bypass trigger on account sometime. I have created custom setting for that and added triggerObject__c field.

In my code

  bypassTrigger__c bypass = 
  bypassTrigger__c.getInstance(UserInfo.getprofileId());
    if(!(bypass.TriggerObject__c.contains('account'))) { 

its throwing Null pointer exception when there is no value in custom setting triggerObject__c .Please suggest

1

You just need to add one null check.

bypassTrigger__c bypass = bypassTrigger__c.getInstance(UserInfo.getprofileId());
if(bypass != null && bypass.TriggerObject__c != null && !(bypass.TriggerObject__c.contains('account'))) { 

Note: If there is no record in the custom setting, your trigger will run.

  • its still not working – sandy Jun 27 at 9:27
  • @sandy updated the code please check – rahul gawale Jun 27 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.