You need to sign in to do that
Don't have an account?
faceroy123
System.NullPointerException: Script-thrown exception
Hi,
Im getting the error message when I update a case record:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Case_CopyConsignmentNumber caused an unexpected exception, contact your administrator: Case_CopyConsignmentNumber: execution of BeforeInsert caused by: System.NullPointerException: Script-thrown exception: (System Code)
Apex trigger Case_CopyConsignmentNumber caused an unexpected exception, contact your administrator: Case_CopyConsignmentNumber: execution of BeforeInsert caused by: System.NullPointerException: Script-thrown exception: (System Code)
I'm trying to search the description field for a unique text string (2 letters followed by 6 letters) and populate the Tracking_job_number__c field with this unique string if this is found.
trigger Case_CopyConsignmentNumber on Case (before delete, before insert) { for(Case c:Trigger.new){ if(c.Description!= null && c.Tracking_Job_Number__c == null){ // First, instantiate a new Pattern object Pattern MyPattern = Pattern.compile('[A-Z]{2}\\d{6}|[a-z]{2}\\d{6}]'); //return a string that contains only numeric values from 0-9 from my original input String ConsignmentNumber = MyPattern.matcher(c.Tracking_Job_Number__c).replaceAll(''); if(ConsignmentNumber!=null){ System.debug('>> found'+ConsignmentNumber); c.Tracking_Job_Number__c=ConsignmentNumber; } } }}
See: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm