- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hello, we're looking at using surveys for our new hires that trigger five days after they start with the organization. This does not seem to be possible with the existing trigger conditions, however. We're holding the employee's start date in their user record & they're created via SFTP import from our HRIS. What is the best way to trigger the surveys?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
you can run a daily scheduled job and check how many days are there for the person to start based on date comparison.
If it's 5 days then trigger survey from script.
Something like this but please enhance with correct table and other details
runSurvey();
function runSurvey() {
try {
var gr = new GlideRecord('task'); // Replace 'task' with your table name
// Find records due in the next 5 days, including today.
gr.addEncodedQuery('due_date>=' + gs.daysAgoStart(-5) + '^due_date<=' + gs.daysAgoEnd(0));
gr.query();
while (gr.next()) {
//For creating survey instances directly from a scheduled job
new SNC.AssessmentCreation().createAssessments('Survey Definition SysId', gr.getUniqueValue(), gr.assigned_to.toString());
}
} catch (ex) {
gs.info(ex);
}
}
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
Monday
you can run a daily scheduled job and check how many days are there for the person to start based on date comparison.
If it's 5 days then trigger survey from script.
Something like this but please enhance with correct table and other details
runSurvey();
function runSurvey() {
try {
var gr = new GlideRecord('task'); // Replace 'task' with your table name
// Find records due in the next 5 days, including today.
gr.addEncodedQuery('due_date>=' + gs.daysAgoStart(-5) + '^due_date<=' + gs.daysAgoEnd(0));
gr.query();
while (gr.next()) {
//For creating survey instances directly from a scheduled job
new SNC.AssessmentCreation().createAssessments('Survey Definition SysId', gr.getUniqueValue(), gr.assigned_to.toString());
}
} catch (ex) {
gs.info(ex);
}
}
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
yesterday
Hope you are doing good.
Did my reply answer your question?
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
yesterday
Yes, it did, we used a slightly different method but I tested using scheduled job w/ a similar script you provided & it also worked. Thank you!