How to get user name and date from email body

NS16
Mega Sage

Hi Experts,
Requipment- ServiceNow will receive below email from xyz system.
?Employee Name (employee ID 100) has been terminated within xyz. Please remove all associated system access for this employee. Effective date is 15/10/2023 11:59:00 PM?
Once received an email we need submit a catalog item.
Question- How can I get Employee Name and effective date from email so that I can use them while submiting a catalog item?

 

Thanks in advance,

NS

1 ACCEPTED SOLUTION

Anubhav24
Mega Sage

Hi,

 

Looks like you need to extract data from the email using string functions. 

Assuming you are receiving the email , you can write an inbound action and in that using the email objects in your case it can be "email.body_text" , this will return you the email body text as plain text and then you can search your string from the email.

For employee name you can use substring  function with the starting position as "0" and ending position to be the position where your bracket starts.

For Effective date you can use the indexOf function to look for effective date text and then use substring to extract date as well.

View solution in original post

6 REPLIES 6

Okay got it, how can I get date with same format?

Assuming date mentioned is always after the text "Effective date is <Date> PM/AM" and that is the last text in that case you can simply extract the string in reverse order to do that you can use slice() function.

Please mark the appropriate response as correct answer and helpful to help others