The CreatorCon Call for Content is officially open! Get started here.

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

 

1 ACCEPTED SOLUTION

RaghavSh
Kilo Patron

This runs and created user when an email is sent from any user from trusted domain and user is not present in sys_user table.

 

It will not fetch any other information. (apart from name and email). For fetching any other information, you need integration with AD of your org.

 

More details in : https://www.servicenow.com/docs/bundle/zurich-platform-administration/page/administer/notification/t... 
Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023
LinkedIn

View solution in original post

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/