The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Pull phone numbers from Email

athavichith
Mega Sage

I turned on 'automatically create users for incoming emails from trusted domain'. Is it possible to pull phone numbers, if phone numbers are associated with the email information? 

athavichith_0-1758556231378.png

 

5 REPLIES 5

kaushal_snow
Mega Sage

Hi @athavichith ,

 

In your inbound email action, use a script in the Script field That reads email.body_text (or email.body) and uses a regular expression to find the phone number. Example:

 

var phoneMatch = email.body_text.match(/Phone:\s*([\d\-\(\)\s]+)/i);
if (phoneMatch && phoneMatch[1]) {
  var phone = phoneMatch[1].trim();
  current.phone_number = phone;  // phone_number is a field created
}

 

After extracting the phone number, link it to the user record (if the user is created or exists). You might query sys_user by email (using email.from) to get the user’s record and set their phone field, or set a custom field on the incident/request/etc....

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/