- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a survey I want to trigger every quarter for members of a particular group.
On the related list of my Survey Definition [asmt_metric_type], I can add trigger conditions, however these seem to require specific events to trigger.
On the Survey Definition record itself, there is the Schedule Period field, but this does not allow anything between monthly and yearly.
What is the solution here?
Regards,
Kim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
The problem is, I did not read the docs carefully enough and I did not realize there is a difference between assessments and surveys.
It says that the second parameter is ONLY for use with assessments. My "assessment" is actually a survey, so the second parameter should be left blank. Thus in my scheduled script:
triggerSurvey();
function triggerSurvey() {
try {
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", "2ccabcccaf3d6a10e8f667caa6274980"); //Group SysID
gr.query();
while (gr.next()) {
new SNC.AssessmentCreation().createAssessments('37b85f99af99ba1056b7a2c651274978' */My survey definition*/, '', gr.user);
}
} catch (ex) {
gs.info(ex);
}
}
Works like a charm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can use scheduled job for this which runs every quarter and trigger survey on particular table record and for particular users
recently I shared solution for something similar on how to trigger survey from script
Schedule an assessment to be sent every quarter
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @kim-lindgren,
To trigger a survey on a quarterly basis, you can use a Scheduled Script Execution instead of relying on Survey trigger conditions or the limited Schedule Period options.
Steps
Navigate to System Definition > Scheduled Jobs.
Click New.
On the “What would you like to automate?” page, select Automatically run a script of your choosing.
Fill out the form:
Name: Schedule ABC Group Survey
Run: Business Calendar: Entry Start
Business Calendar: Quarter
- In the Run this script field, enter:
var surveyID = 'YOUR SURVEY SYSID';
var response = new SNC.AssessmentCreation().createAssessments(surveyID);
This scheduled job will generate and send the survey invitations every quarter, bypassing the limitations of the Survey Definition's built-in scheduling options.
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks both of you for your suggestions!
@M Iftikhar I went with your solution as it seemed easiest and it is working great.
