Trigger Survey Using Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 11:36 AM
I have a survey created. I want to to trigger it only when the hr case is closed by the user of the assignment group "Tier1"
So any of the user from the assignment group changes the state to close complete the survey named as "Survey for HR Case" will be triggering.
Is there any way of achieving this..if yes
Pls provide me the sample code.
Thankyou
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 05:37 AM
you need not worry on that, it's at platform level and we won't find it
But it does work.
share your script
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 05:50 AM
(function executeRule(current, previous /*null when async*/) {
var groupSysId = current.assignment_group; // or current.assignment_group.sys_id if you prefer
var tierGroups = [
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // sysid
'yyyyyyyyyyyyyyyyyyyyyyyyyyyyy' // sys_id
];
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('user', current.sys_updated_by);
grMember.addQuery('group', 'IN', tierGroups.join(','));
grMember.query();
if (grMember.hasNext()) {
var assessment = new SNC.AssessmentCreation();
assessment.createAssessments('sysid of survey', '', current.opened_for.toString());
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 05:52 AM
you should pass the record sysId against which the Survey has to trigger
if your BR is on HR case then it should send HR case sysId
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 06:52 AM