Trigger survey from schedule job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 02:20 AM
hi contributors,
i have requirement, to send survey mail , half yearly.
survey to be triggered to all unique requestor whose requests is closed , in last half year.
survey is already designed in survey designer. Please suggest on, how to trigger it with above mentioned logic.
Thanks
Ujjwal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 03:04 AM
Hi @Ujjwal1
1. Use ServiceNow Survey Designer
Since your survey is already designed, ensure:
It’s published and accessible.
Responses are stored in the Survey Results table (asmt_metric_result).
2. Automate Survey Assignment
Create a Scheduled Job or Business Rule to automatically trigger the survey for closed requests.
Scheduled Script Execution Example
You can set this up to run based on your time, selecting all closed requests and assigning surveys.
var sixMonthsAgo = new GlideDateTime();
sixMonthsAgo.addMonthsUTC(-6);
// Query closed requests
var grRequest = new GlideRecord('your_request_table'); // Replace with the correct table name
grRequest.addQuery('state', 'closed');
grRequest.addQuery('closed_at', '>=', sixMonthsAgo);
grRequest.query();
while (grRequest.next()) {
var surveyInstance = new GlideRecord('asmt_assessment_instance');
surveyInstance.initialize();
surveyInstance.user = grRequest.requestor; // Assign survey to requestor
surveyInstance.assessment = 'your_survey_sys_id'; // Replace with actual survey ID
surveyInstance.insert();
}
gs.info('Survey instances created for closed requests.');
3. Track Responses
Responses will be stored in the Survey Results table.
Use reports and dashboards to analyze feedback trends.
"Kindly mark this post as helpful or accept it as the solution if it resolved your issue."
Regards,
Roshnee
Stay awesome.
Stay awesome,
Roshnee Dash