Can we query substring value with a field value in GlideRecord

amanimogili
Kilo Contributor

Hi All,

We had a requirement on Email to ticket Integration. Here, we have to assign the ticket to a assignment group based on the substring in the email subject.

Ex: LCI1 Job NTM6839W (JOB09692), has failed @ 06:08:10 19 Mar 2018

Here, "NTM" is considered as mnemonic and based on that we have to assign the ticket to a assignment group.

We have created a custom table with mnemonics and assignment groups and GlideRecord this table in Inbound email action which is not working.

Below is the how we are querying the table:

 

current.caller_id = gs.getUserID();
current.u_impacted_id = gs.getUserID();
var str = email.subject.substring(8, 12).toString();
var gr = new GlideRecord('u_tws_integration');
gr.addQuery('u_mnemonics','str');
gr.query();
if(gr.next())
{
gs.log(str,'tws');
gs.log(gr.u_group,'tws');
current.assignment_group = gr.u_group;
}
else
{
current.assignment_group = 'c18c447ddb4d2e0006a6f9b9af961920';
}

 

Can someone help me on the above issue.

 

Thanks in Advance!

1 ACCEPTED SOLUTION

Mihir Mohanta
Kilo Sage

Change 

var str = email.subject.substring(8, 12).toString();

line to

var str = email.subject.substring(9, 12).toString();

 

and check.

View solution in original post

7 REPLIES 7

amanimogili
Kilo Contributor

Hi Mihir,

 

I am using the current.insert() operation to insert the incident record.

Below is the my complete Inbound action script

current.caller_id = gs.getUserID();

current.u_impacted_id = gs.getUserID();

var str = email.subject;
var str1= str.substring(8, 12).toString();
var gr = new GlideRecord('u_tws_integration');
gr.addQuery('u_mnemonics',str1);
gr.query();
if(gr.next())
{
current.assignment_group = gr.u_group;
}
else
{
current.assignment_group = 'c18c447ddb4d2e0006a6f9b9af961920';
}

current.location = current.caller_id.location;
current.u_location_type = '';
current.category='';
current.subcategory='';
current.cmdb_ci = '';

current.description = "received from: " + email.origemail + "\n\n" + email.body_text;
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";

if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high")
current.priority = 1;
}

current.insert();

Mihir Mohanta
Kilo Sage

Change 

var str = email.subject.substring(8, 12).toString();

line to

var str = email.subject.substring(9, 12).toString();

 

and check.

It worked like a Charm!!

 

Thank you