How to retrieve value from a table in an inbound action

ceraulo
Mega Guru

Hello ServiceNow Gurus,

I am creating an inbound action that processes incoming emails which always contain a table. One of the rows is similar to the screenshot below.

find_real_file.png

 

is it possible to retrieve this value and match the email address to a record in the User table? The User name will then populate the caller field in the Incident table.

Please help.

Thank you very much.

1 ACCEPTED SOLUTION

here we go 

 

sample code:

 

var abc = email.body_text;
var op=abc.split('Email');
var res= op[1];
var em= res.split('Sender');
var fr = em[0].trim();
gs.log('Result is'+fr);

 

give a try and let me know if you need any further help here. 

 

 

View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

yes you can do that. 

you can write gliderecord query to fetch the details .

 

var em ='your email which is comiing from email body ';

var gr = new GlideRecord('sys_user');

gr.addQuery('email',em);

gr.query();

if(gr.next()){

gs.log('Email Exist'+ gr.sys_id);

}

Thank you! This works.

However, I also need to extract the email address from the table. How can I do that?

you mean , you want to extract from the email body ?

is yes then below line will help you. 

 

var abc = email.body.email;

 

or if you want to get from glide record query then use gr.email 

Our ServiceNow mailbox receives email, where in the email body contains a table similar to below.

find_real_file.png

The requirement is to retrieve the email address, check the User record who owns this email address, then set the owner as the Caller.

The first part is what I cannot figure out, which is to get the email value.