how to send survey response of a particular user through mail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2016 12:36 AM
Hi all,
we have this requirement to send survey response of a user to a manager through email.i know responses are saved in metric results table. But where is the form view of response present? If form view is not available can i create it?
Please help me with this.
Thanks,
Ramya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 05:56 AM
Hello Angus,
Sorry I missed your question earlier. The asmt_metric_result table records as individual records the response to each question in your survey - that's why it's triggering an email for every question - each question/response is a record on that table. Then your mailscript goes up a level (to the assessment instance) and grabs the details of all the questions associated with that survey. I see at least 2 options for you:
- Add a filter on your notification so that it only runs when a specific metric is inserted, or is inserted with a specific value. For example, mine only goes when the 'metric is manager_response' AND 'string value is yes'. OR
- Trigger the notification instead from the Instance table (asmt_assessment_instance), but then you'd have to adjust the mailscript. Without testing it myself, I think you'd just adjust it so that the query for "instance" would just be "current", rather than dot walking from the metric result to the instance.
I'll put this in both places so future searchers can see it.
Sincerely,
Meghan Smith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 04:11 AM
I had a go with this but I'm not a coder - so no surprise it didn't work
My new email script:-
template.print("<p></p>Results:<br />");
var gr = new GlideRecord("asmt_assessment_instance");
gr.addQuery('current.metric');
gr.query();
while(gr.next()) {
template.print(gr.metric.getDisplayValue() + ": " +gr.string_value + "<br />");
}
However when I preview the notification all it shows me below Results is many lines of undefined undefined.
Any suggestions please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 04:26 AM
Hi,
I'm at a conference today so I can't test. At a glance, try just 'current' rather than current.metric. You're on the assessment instance table, and you just want to to limit the query to the current sysId. The next part walks through each metric and prints it, so all you have to do is point it to the correct instance.
-
Meghan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2017 06:27 AM
Thanks for your response despite the fact your out of the office. I tried as you said but got the same results.
A line if undefined undefined for every question ever asked - thankfully not that many at this stage.
I had slightly better luck with the following - at least it picked up the actual question asked however for the string value I still got undefined and I also got a result for every question ever asked.
template.print("<p></p>Results:<br />");
template.print("<br> <br />");
var gr = new GlideRecord("asmt_metric_result");
gr.addQuery('current');
gr.query();
while(gr.next()) {
template.print(gr.metric.getDisplayValue() + ": " +gr.metric.string_value + "<br />");
}
Have a great weekend
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 11:10 AM
Hi Meghan,
Can you guide me how to print these survey responses in the order which was displayed in actual survey. Currently the survey responses are not coming in order using this script.