You need to sign in to do that
Don't have an account?
Staci
if(objCase.CW_Current_User_s_Role__c == '00E300000019awI' && objCase.CW_Queue_Case_Owner__c.contains('Dealer'))
CWUserValidation: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.CWUserValidation: line 17, column 1
Not sure what I'm doing wrong here, can anyone help?
Contains in Trigger is erroring
trigger CWUserValidation on Case (before update) { for (Case objCase : Trigger.new) { //If the current user is a Tier 2 user and they assign the case to a Tier 3 user, throw error. if(objCase.CW_Current_User_s_Profile__c == 'CW MineStar Support - Tier 2' && objCase.CW_Owner_Role__c == '00E300000019awI') { trigger.new[0].addError('You cannot assign a case directly to a Tier 3 user. Please choose a Tier 3 queue.'); } //If the current user is a Tier 3 user and they assign the case to a Tier 2 user, Dealer user or Dealer Queue, throw error. if(objCase.CW_Current_User_s_Role__c == '00E300000019awI' && (objCase.CW_Owner_Role__c == '00E300000019awS'||objCase.CW_Owner_Role__c == '00E300000019awc'||objCase.CW_Owner_Role__c == '00E300000019awX'||objCase.CW_Owner_Role__c == '00E300000019awN')) { trigger.new[0].addError('You cannot assign a case directly to a Tier 2 user, Please assign to the CW Support Advocate (L2) Queue.'); }else{ //If the current user is a Tier 3 user and they assign the case to a Dealer queue, throw error if(objCase.CW_Current_User_s_Role__c == '00E300000019awI' && objCase.CW_Queue_Case_Owner__c.contains('Dealer')) { trigger.new[0].addError('You cannot assign a case to a Dealer queue, Please assign to the CW Support Advocate (L2) Queue.'); }else{ //If the current user is a Tier 3 user and they assign the case to a Dealer user if(objCase.CW_Current_User_s_Role__c == '00E300000019awI' && objCase.CW_Owner_Profile__c == '00e30000001aw4D') { trigger.new[0].addError('You cannot assign a case to a Dealer user, Please assign to the CW Support Advocate (L2) Queue.'); } } } } }My trigger if it hits this line, it errors with the error below:
if(objCase.CW_Current_User_s_Role__c == '00E300000019awI' && objCase.CW_Queue_Case_Owner__c.contains('Dealer'))
CWUserValidation: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Trigger.CWUserValidation: line 17, column 1
Not sure what I'm doing wrong here, can anyone help?
All Answers
Try below code.I have updated code at Line#17.
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.