How to send survey to a user once per a week
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 07:58 AM
Hello All,
We have a requirement to send survey to user once a week for all his incident resolved in that week
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 08:14 AM
HI @nayeemsk263 ,
I trust you are doing great.
Create a new table to store survey responses:
- Name the table as "Survey Responses".
- Add fields such as "User" (reference to User table), "Incident" (reference to Incident table), "Rating" (integer field for survey rating), and any other relevant fields.
Create a Business Rule to trigger the survey workflow:
- Write a Business Rule on the Incident table's "State" field.
- Set the conditions to trigger the Business Rule when an incident is resolved.
- In the Business Rule script, schedule a workflow to send the survey to the user.
Create a workflow to send the survey:
- Define a new workflow in ServiceNow's Workflow Editor.
- Set the "Run" field to "Scheduled" and configure it to run weekly.
- Add an "Email" activity to send the survey email to the user.
- Include the survey questions and a link for the user to submit their responses.
- On completion of the workflow, create a new survey response record in the "Survey Responses" table.
Here's an example code snippet for the Business Rule:
(function executeRule(current, previous) {
// Check if incident is resolved
if (current.state === 7) {
// Schedule the survey workflow
var surveyWorkflow = new GlideRecord('wf_workflow');
if (surveyWorkflow.get('name', 'Survey Workflow')) {
var schedule = new GlideSchedule();
schedule.setFixed();
schedule.setRecurrence(1); // Weekly recurrence
schedule.setType('W');
var workflowContext = new GlideScriptableWorkflowContext(current);
var workflow = workflowContext.newWorkflow();
workflow.scratchpad.schedule = schedule;
workflow.scratchpad.user = current.caller_id.toString();
workflow.scratchpad.incident = current.sys_id.toString();
workflow.startFlow(surveyWorkflow.sys_id.toString(), workflowContext);
}
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi