send survey after every 10 closed incident?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 12:56 PM
I need to send incident survey on repeated interval of 10 incident closure. I tried setting the trigger condition based on Number ends with 0, but that's not a concrete solution. Has anyone done this before?
Help much appreciated, thanks !
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2017 09:37 PM
For exact count of 10,You write a script include like below and call the script include in the trigger business rule condition.
var checkCount = Class.create();
checkCount.prototype = {
initialize: function() {
this.frequency = 10;
},
checkTaskCount : function()
{
var lastTriggerID = this.lastSurveyTakenFor(incident,'87186844d7211100158ba6859e610378'); //Table Name and Metric type.
if(lastTriggerID){
var inc = new GlideRecord('incident');
inc.get(lastTriggerID);
var closedAt = inc.closed_at;
var incident = new GlideRecord('incident');
incident.addNotNullQuery('closed_at');
incident.addQuery('closed_at','>=',closedAt);
incident.orderByDesc('closed_at');
incident.chooseWindow(this.frequency-1,this.frequency);
incident.query();
if(incident.next()){
return true;
}
else{
return false;
}
}
return true;
},
lastSurveyTakenFor : function(tableName,metricType)
{
var gr = new GlideRecord('asmt_assessment_instance');
gr.addQuery('trigger_table',tableName);
gr.addQuery('metric_type',metricType);
gr.addQuery('trigger_id','!=','');
gr.query();
if(gr.next())
{
return gr.trigger_id;
}
else
{
return false ;
}
},
type: 'checkCount'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 06:31 AM
Thanks Rakesh,
I'll test and update you. Just to confirm, if i change 'this.frequency = 10;' to 'this.frequency = 3;' , the survey will send after every 3 incidents? Also, when you say "call the script include in the trigger business rule condition.", it means the business rule that is set in the trigger condition? Right now I have this setup in my BR script:
function onAfter(){
(new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, 'e127cb9adb843a00d4385540cf961987');
}
Do I need to remove it and just call the script Include?
Thanks in advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 07:23 AM
Yes, Changing frequency will do.
Don't change any thing in the script.But in BR condition call script include as new checkCount().checkTaskCount();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 08:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-05-2017 08:39 AM
What is the metric type you are passing in the script include? Is it same sys_id of your survey?