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

Sai Kumar B
Mega Sage

@Happy S 

You can use the following query in your survey trigger script to ignore re-opened incidents

 

 

trigger_table=incident^state=wip^ORstate=ready^task_id.ref_incident.reopen_count!=0

 

 

@Sai Kumar B I added the query but it will still trigger surveys for tickets that got resolved earlier but is currently in the Active state 

 

I do not want surveys to be triggered for reopened tickets which are in one of the current states below..

State = Active/In Progress/On Hold

Incident State = Active/In Progress/On Hold

 

Thank you..

 

@Happy S Can you check the Re-open count value for those incidents?

yes I had a few incidents where the state is in progress and reopen count is >1 but still gets the surveys