Populate CI Name in Configuration Item field from email received in SNOW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 12:03 PM
Hello Team,
Currently, we have configured an Inbound Action for Incident Ticket creation for all emails received from a specific email id and when the Subject contains "Resolution state: New".
Below is the Inbound Script.
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
gs.include('validators'); {
var fromaddress = email.origemail;
var severity = email.body.severity;
var pri = email.body.priority;
var ci = email.body.path;
//gs.logs("Severity= " +severity+ "\n Priority= "+pri);
// current.comments="Severity: "+severity+"\n Priority:" +pri;
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.description = email.body_text;
current.short_description = email.subject + " - " + ci;
current.incident_state = 1; //Incident state = New
current.state = 1;
current.contact_type = "Alert";
current.assignment_group = 'a7d3b8241b7ab49040d9eb97624bcb01'; //Assignment Group: ALM-SRM Grp
current.category = "server";
current.subcategory = "SCOM";
current.incident_state = 1;
current.caller_id = 'e21259021b5d85507f0132e2cd4bcbd4';
current.opened_by = 'e21259021b5d85507f0132e2cd4bcbd4';
if (severity == 2 && pri == 2) { // P3 - Medium
current.urgency = 2;
current.impact = 2;
} else { //P4 - Low
current.urgency = 3;
current.impact = 3;
}
current.insert();
event.state = "stop_processing";
}
})(current, event, email, logger, classifier);
Now they want to populate the CI Name as well from the email body from Source Field into the Configuration Item field on the Incident form.
Can anyone help me out in modifying the script to make this work to populate the required CI Name from Source Field from email body to Configuration Item Field on the Incident form? It is very urgent for me to achieve this requirement and confirm with the customer.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 06:04 AM
That was what I thought it was based on what I could see in the screenshot. And yes, my example I provided in my last post should do what you are wanting, with that one minor edit of removing the space after the :
I got caught the "other" way with a similar script in that I thought it was one space, but it turned out to be two on a string I was extracting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2022 03:34 AM
Hello Ian,
We have received too many test alerts in our Dev Instance but none of them worked properly as expected i.e., the CI Name didn't got populated on CI Field and that I think because of the space after Source:
Now I have removed the space, so is it going to work for me or any other modifications we need to perform here.
var getSource = email.body_text;
var sourceName = [];
sourceName = getSource.toString().split("Source:");
var spl = sourceName[1].split(".");
current.cmdb_ci.setDisplayValue(spl[0].toLowerCase());
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2022 04:55 AM
I did mention that you might need to go in and remove that space. Other than that, the script should do what you are wanting; as I have several similar scripts doing various similar duties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 04:07 AM
Hello Ian,
I am feeling very bad to confirm that the script is not working as expected.Even though we are receiving the same alerts created in Production but the CI Name is not getting splitted from Source field and populated in CMDB CI Field.
Can you please help me out on this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 05:22 AM
There should only be a couple of reasons this would fail:
1. The split is being defined incorrectly
2. The extracted value has no match in the target reference field/table
I went back to look at your screenshots and compared to some of my old test emails and noticed a large difference. In your screenshot it is showing "Detailed Description". That is not a "sys_email" field so it cannot be used in this respect of creating the function.
What is the contents of the "body" field from the actual received email?