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

Ahmmed Ali
Mega Sage

You can access incident record fields in your script as below:

 

var asint1 = new GlideRecord('asmt_assessment_instance');
asint1.addEncodedQuery("trigger_table=incident^state=wip^ORstate=ready");
asint1.query();
while (asint1.next()) {

 

//Check if incident is reopened

//Validate the state values for active, in progress and on hold

if(asint1.trigger_id.state == "1" || sint1.trigger_id.state == "2" || sint1.trigger_id.state == "3"){

continue; //This will cause loop to not execute for current record

}


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();

}
}

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

unfortunately this seems to be not working..

Ahmmed Ali
Mega Sage

Can you add log statement as below to see what value you are getting?

 

gs.log("Incident State: " + asint1.trigger_id.state);

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

this is what I get..

 

com.glide.script.RhinoEcmaError: "sint1" is not defined.
<refname> : Line(12) column(0)
9:
10: //Validate the state values for active, in progress and on hold
11:
==> 12: if(asint1.trigger_id.state == "1" || sint1.trigger_id.state == "2" || sint1.trigger_id.state == "3"){
13:
14: continue; //This will cause loop to not execute for current record
15:

 

Thank you

Sorry, there was typo in the if condition.

Replace if with below:

if(asint1.trigger_id.state == "1" || asint1.trigger_id.state == "2" || asint1.trigger_id.state == "3")

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali