You need to sign in to do that
Don't have an account?
Jeremiah Sherrill
String replacement regex System.NullPointerException: Attempt to de-reference a null object
Trying to return only the numbers from a phone number and remove extraneous data, works just fine, I removes brackets, lines, all clean code but when I run tests on my code I get back System.NullPointerException: Attempt to de-reference a null object.
String udp_billing_contact_number = serviceOrder[0].Billing_Contact_Phone_Number__c; String udp_contact_number = udp_billing_contact_number.replaceAll('[^0-9]', '');
Try replacing line 2 with:
String udp_contact_number = udp_billing_contact_number==null ? null : udp_billing_contact_number.replaceAll('[^0-9]', '');
All Answers
Try replacing line 2 with:
String udp_contact_number = udp_billing_contact_number==null ? null : udp_billing_contact_number.replaceAll('[^0-9]', '');