survey is not triggering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2025 09:08 AM
Hi Team,
Created two incidents with 2 different groups,
Incident 1 --caller--Abel Tuter
incident assignment group is > Test ITIL GROUP
Inciden2 – Requested by --Abel Tuter
incident assignment group is > Test ITIL GROUP2
when the incident state changes to closed, survey is triggering.
Survey Repeat Interval= Repeat interval is 7days
current behavior:
For > Incident1 survey triggered as per trigger repeat condition
For > Incident2 survey will not trigger as per trigger repeat condition
Expected behavior :
If assignment group is different and caller is same person, then survey should trigger.
How to achieve this ?
Regards,
Abhilasha G T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 05:18 AM - edited 02-16-2025 05:20 AM
Hello Abhilasha, I think this is not possible to accomplish by a simple way. You have to customize survey trigger logic:
- Open Trigger Condition record in Trigger Conditions table [asmt_condition]
- Set Repeat Interval to zero
- Note the Trigger Condition Sys ID
- Open Business Rule defined in Business Rule (business_rule) field
- Check if the business rule's when to run condition is set to after, if not, change it.
- Put this code in Script field. Replace my trigger Sys ID (249e70b0875013005d90bba826cb0bbf) by your's noted in step 3
function onAfter(current) {
if (!assessmentForAgAlreadyExist()) {
(new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, '249e70b0875013005d90bba826cb0bbf');
}
}
function assessmentForAgAlreadyExist() {
var triggerSysID = '249e70b0875013005d90bba826cb0bbf';
var assignmentGroup = current.getValue('assignment_group');
var currentUser = current.getValue(getTriggerCondition(triggerSysID, 'user_field'));
var assessmentSysID = getTriggerCondition(triggerSysID, 'assessment');
var assessmentGR = new GlideRecord('asmt_assessment_instance');
assessmentGR.addQuery('user', currentUser);
assessmentGR.addQuery('metric_type', assessmentSysID);
assessmentGR.addQuery('trigger_id.assignment_group', assignmentGroup);
// Encoded query - created in last 7 days
assessmentGR.addEncodedQuery('sys_created_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');
assessmentGR.query();
if (assessmentGR.hasNext()) {
return true;
} else {
return false;
}
}
function getTriggerCondition(triggerSysID, field) {
var triggerGR = new GlideRecord('asmt_condition');
if (triggerGR.get(triggerSysID)) {
return triggerGR.getValue(field);
}
}
Warning: This is a quite volatile customization. If you modify trigger condition record, this Business Rule gets updated and script gets overwritten!
If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin