populating task details on survey form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 09:41 PM
i have created a survey which will trigger when the incident or request will be moved to resolved state . my requirement is to populate the incident or request details to which the user is giving the survey on the survey form itself how can i achieve this
this is how i modeled it but now i want the respective incident details to be populated to which this incident is triggering on the form itself . how can i acheive it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 07:26 AM
Good day,
When you say you "want the respective incident details to be populated to which this incident is triggering on the form itself" - Can you specify where on the form you want these details to be populated?
For example, would you like these survey answers to appear in the Work Notes of the incident? Or are you going to make custom fields for each survey question?
Alternatively perhaps you'd like the Survey Instance to be quickly accessible from the instance - In which case I would recommend you have a reference field which automatically gets set with the Survey Instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2024 09:23 AM
i want to display the details of the incident on survey form in single line text field creaated in it with lables number and short description and description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 08:11 AM
@chaitanyakumarD - The below is working on my PDI. I hope it helps. If it does, please mark this as the solution.
Create a Business Rule on the [asmt_assessment_instance] table
- Advanced: true
- When: After Update
- Filter conditions: State is Complete
- Advanced:
(function executeRule(current, previous /*null when async*/) {
var questionPayload = ""; // Will be filled with questions later
var triggerTask = new GlideRecord("task");
triggerTask.get(current.trigger_id); // This is the Task record that triggered the Survey
var surveyQuestions = new GlideRecord("asmt_assessment_instance_question");
surveyQuestions.addQuery("instance", current.sys_id);
surveyQuestions.query(); // These are all the questions asked in the Survey
while (surveyQuestions.next()) { // Loop through every question in the Survey
if (surveyQuestions.value == 0) { // The question is string based
questionPayload += surveyQuestions.metric.getDisplayValue() + ": " + surveyQuestions.string_value + "\n";
} else { // The question is number based (such as smiley faces)
questionPayload += surveyQuestions.metric.getDisplayValue() + ": " + surveyQuestions.value + "\n";
}
}
triggerTask.work_notes += questionPayload;
triggerTask.update(); // Update outside of the loop so we get one singular update on the Task
})(current, previous);
The Business Rule above will run once a Survey has been completed, and will pop the questions and their answers into the relevant task record like so...
Please mark this has helpful if it was useful. Please mark it as the solution if it solved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 03:35 AM
@chaitanyakumarD you can use the method above but instead of updating the work notes on the second-to-last line, you can update the string field that you're after.