- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 08:43 AM
I have the following script in an inbound action. It is working, but it is creating duplicate incidents. I am missing something. I have the field actions set to assign to the proper group, I thought that maybe this was causing an issue and tried using the script to assign to the correct team, but that did not stop the duplicates from being created.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 08:50 AM
@rueben Please update your script as follows and let me know if it works.
var shortDescription = email.body_text.substr(email.body_text.indexOf("Proxy:")+0,30);
var shortDescription2 = email.body_text.substr(email.body_text.indexOf("Alert Name:")+0,19);
current.short_description = shortDescription2 + ' ' + shortDescription;
//Check for Current Open Incident and Update
var eSubject = email.subject;
var shorDesc = current.short_description;
var efrom = email.from;
var grInc = new GlideRecord('incident');
var grEmail = new GlideRecord('sys_email');
var incUpdated = false;
grEmail.addEncodedQuery('sys_created_onRELATIVEGE@hour@ago@24^user=' + efrom + '^subject=' + eSubject);//updated to 24 from 12
grEmail.query();
if(grEmail.getRowCount != 0){
while(grEmail.next() && incUpdated != true){
grInc.get(grEmail.instance);
if(grInc.active == true){
incUpdated = true;
grInc.work_notes = '\nFrom: ' + email.from + '\nTo: ' + email.to + '\nSubject: ' + email.subject + '\n\n' + email.body_text;
grInc.update();
}
}
} //Creates a new Incident
if(incUpdated == false){
current.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 08:50 AM
@rueben Please update your script as follows and let me know if it works.
var shortDescription = email.body_text.substr(email.body_text.indexOf("Proxy:")+0,30);
var shortDescription2 = email.body_text.substr(email.body_text.indexOf("Alert Name:")+0,19);
current.short_description = shortDescription2 + ' ' + shortDescription;
//Check for Current Open Incident and Update
var eSubject = email.subject;
var shorDesc = current.short_description;
var efrom = email.from;
var grInc = new GlideRecord('incident');
var grEmail = new GlideRecord('sys_email');
var incUpdated = false;
grEmail.addEncodedQuery('sys_created_onRELATIVEGE@hour@ago@24^user=' + efrom + '^subject=' + eSubject);//updated to 24 from 12
grEmail.query();
if(grEmail.getRowCount != 0){
while(grEmail.next() && incUpdated != true){
grInc.get(grEmail.instance);
if(grInc.active == true){
incUpdated = true;
grInc.work_notes = '\nFrom: ' + email.from + '\nTo: ' + email.to + '\nSubject: ' + email.subject + '\n\n' + email.body_text;
grInc.update();
}
}
} //Creates a new Incident
if(incUpdated == false){
current.insert();
}