- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 09:17 PM - edited 11-01-2022 09:22 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 05:55 AM
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();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 10:19 PM
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();
}
}
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 11:59 PM
unfortunately this seems to be not working..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 12:14 AM
Can you add log statement as below to see what value you are getting?
gs.log("Incident State: " + asint1.trigger_id.state);
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 12:31 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 12:39 AM
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")
Thank you,
Ali