Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Do not trigger survey for reopened Incident tickets

Happy S
Tera Expert

Currently we have a scheduled script that will send out reminders to users that have their Incident tickets resolved after 5 days, even to users that have their tickets reopened in between, with the condition that these users have not taken the survey

 

How to add the field reopen_count to my script below, so that any tickets that got resolved and reopened in between, with not receive the surveys? only until the reopened ticket is resolved then only a survey will be triggered to the user

 

var asint1 = new GlideRecord('asmt_assessment_instance');
asint1.addEncodedQuery("trigger_table=incident^state=wip^ORstate=ready");
asint1.query();
while (asint1.next()) {
var gdt1 = new GlideDateTime(asint1.sys_created_on);
gdt1.addDaysUTC(5); //add 5 days
var dateaftr5 = gdt1.getDate();
dateaftr5 = dateaftr5.toString();
var gdt3 = new GlideDateTime();
var todaydat = gdt3.getDate();
todaydat = todaydat.toString();

}
}

 

thank you

 

 

1 ACCEPTED SOLUTION

Happy S
Tera Expert

Thank you..I added the query below in italic and it worked..

 

 

 

 

var asint1 = new GlideRecord('asmt_assessment_instance');
asint1.addEncodedQuery("trigger_table=Incident^state=wip^ORstate=ready^task_id.ref_incident.incident_stateNOT IN1,2,3");
asint1.query();
while (asint1.next()) {
var gdt1 = new GlideDateTime(asint1.sys_created_on);
gdt1.addDaysUTC(5); //add 5 days
var dateaftr5 = gdt1.getDate();
dateaftr5 = dateaftr5.toString();
var gdt3 = new GlideDateTime();
var todaydat = gdt3.getDate();
todaydat = todaydat.toString();

}
}

View solution in original post

10 REPLIES 10

Happy S
Tera Expert

Thank you..I added the query below in italic and it worked..

 

 

 

 

var asint1 = new GlideRecord('asmt_assessment_instance');
asint1.addEncodedQuery("trigger_table=Incident^state=wip^ORstate=ready^task_id.ref_incident.incident_stateNOT IN1,2,3");
asint1.query();
while (asint1.next()) {
var gdt1 = new GlideDateTime(asint1.sys_created_on);
gdt1.addDaysUTC(5); //add 5 days
var dateaftr5 = gdt1.getDate();
dateaftr5 = dateaftr5.toString();
var gdt3 = new GlideDateTime();
var todaydat = gdt3.getDate();
todaydat = todaydat.toString();

}
}