Populate CI Name in Configuration Item field from email received in SNOW

SNOW46
Tera Contributor

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.

find_real_file.png

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

19 REPLIES 19

Hello Ian,

I think we are somehow going in the wrong direction as we need to check or fetch the CI name from CMDB Table and then populate it in the CI field on Incident Form.

Do we need to glide the record here in the script?

Still the script is not working for me? Please help me here as I need to have a demo on this.

 

Thanks

If the value being extracted from the email body is the name of a current CI entry, then it should work as I showed in the example.

AS the Configuration Item field on an Incident form is a reference lookup, it should take the entered value and do the lookup/match for you.

Jaspal Singh
Mega Patron
Mega Patron

Since, its in name: value pair below should work

current.cmdb_ci=email.body.source; 

You can add it just before current.insert(); line

Hello Jaspal,

I have added the line of code given by you but it didn't worked for me.

 

Thanks

Can you do below & confirm the logs

current.cmdb_ci=email.body.source; 

gs.log('CMDB Source is '+email.body.source);

just before

current.insert();