Inbound Email Action - Pass CI from 'Sender' of email

GMoon
Tera Guru

Hi all,

 

Looking for support on the correct syntax for an Inbound Email Action. We have an action in situ working, however, we now need to pass the CI (which is captured in the From field of the incoming email) into the Configuration Item field on the Incident form.

Could someone assist with adding the correct syntax to our existing script please? I believe it would be something along the lines of the below, however, I can't work out how to only pass the CI value, as opposed to all the information in the Sender field of the incoming email.

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION

@GMoon 

is it prefix or suffix?

if 1st letter at the start of string is to be removed then use this line

var exampleCI = inputString.split('.')[0].substring(1).toLowerCase();

if last letter at the end of string is to be removed then use this line

var exampleCI = inputString.split('.')[0].slice(0, -1).toLowerCase();

I believe I have answered your question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

J Siva
Tera Sage

Hi @GMoon 

Could you please share the sample email?
Reagrds,
Siva

Hello,

Yes of course, please see below:


Subject: HPE iLO AlertMail-032: (REPAIRED) 

From: EXAMPLECI.xxxx.local@smtprelay.xxx.local 

To: service.now@xxxx.com 

The 'EXAMPLECI' is the value I need to pass into the CI field on the Incident form and always comes in uppercase format.
Thanks.

Hi @GMoon 
You can use "email.origemail" in place of email.from.
Also if you want only the fiest half of the from address then, you need to use,

var emailFrom= email.origemail;
var ci = emailFrom.split('.')[0];

Note:The above script will work only if the CI name doesn't conatins dot(.).

For more details please review below doc.
https://www.servicenow.com/docs/bundle/yokohama-platform-administration/page/administer/notification...

Regards,
Siva

Hi Siva,

I tested your suggestion but unfortunately it was not successful. This is my updated script:

var emailFrom= email.origemail;
var ci = emailFrom.split('.')[0];

//current.caller_id = gs.getProperty('xxx.caller.id');
current.short_description = "Remote site hardware problem";
current.description = email.body_text;
current.type = '8';
//current.location = gs.getProperty('xxx.location');
current.assignment_group =  gs.getProperty('xxx');
current.priority = '3';

current.contact_type = 'alert';
current.cmdb_ci = ci;
current.urgency = '3';
current.impact = '3';
current.category = 'Application';
current.insert();
event.state="stop_processing";