- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 03:38 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 04:14 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:05 AM
the from field in inbound is the recipient i.e. some email address
how will you set that in CI field?
CI field on incident refers cmdb_ci table
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 04:08 AM - edited 04-07-2025 04:09 AM
Hi Ankur,
These particular emails are like the below, they don't come from a 'typical' sender but a relay which has the CI prefixed at the start.
From: EXAMPLECI.xxxx.local@smtprelay.xxx.local
These CI's are all in our cmdb_ci table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 05:37 AM
then is "EXAMPLECI" a name of CI in cmdb_ci table?
If yes then this try this
// see where this email comes either from email.fromAddress or email.from or email.origemail
var inputString = email.fromAddress.toString();
// Extract the EXAMPLECI part
var exampleCI = inputString.split('.')[0].toLowerCase();
// Query the cmdb_ci table to find the matching record
var ciGr = new GlideRecord('cmdb_ci');
ciGr.addQuery('name', exampleCI);
ciGr.query();
if (ciGr.next()) {
var sysId = ciGr.sys_id;
current.cmdb_ci = sysId;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 05:51 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 03:56 AM
Hi Ankur,
Our testing was unsuccessful but I have noticed the CI format contained within the incoming email is prefixing an additional letter on the end, therefore I feel that may be our issue.
This is a long shot but is there any way we can change the script to omit the additional letter?
Thanks