how to send survey response of a particular user through mail

thakkallapallay
Tera Contributor

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

16 REPLIES 16

meghansmith
Kilo Expert

Hi Ramya,



We wanted to come up with the same thing - our survey asks if they'd like to be contacted by a manager.   It's a notification set on the asmt_metric_result table with the filter when METRIC is MANAGER CONTACT and STRING VALUE is YES.



${user.first_name} ${user.last_name} filled out the Service Satisfaction survey and asked to be contacted by the Service Desk Manager.


The survey was kicked off by the resolution of ${instance.trigger_id.URI_REF}.   You can reach ${user.first_name} (VIP Status: ${user.vip}) at ${user.email} or ${user.phone}.


Here are ${user.first_name}'s answers:


${mail_script:survey_results}




The survey_results script looks like this:


template.print("<p></p>Results:<br />");


var gr = new GlideRecord("asmt_metric_result");


gr.addQuery("instance", current.instance);


gr.query();



while(gr.next()) {


  template.print(gr.metric.getDisplayValue() + ":   " +gr.string_value + "<br />");


}



Bringing it together, the email to managers looks like:



MEGHAN SMITH filled out the CDM Smith Service Satisfaction survey and asked to be contacted by the Service Desk Manager.


The survey was kicked off by the resolution of INC0083383. You can reach RANI IDAH (VIP Status: false) at msmith@test.com or 6148475555.  


Here are MEGHAN's answers:


Results:
What was the main method of contact that the Service Desk used to resolve the incident?: Chat
Communication regarding the progress of issue resolution:: Neutral
Would you like the Service Desk Manager to contact you?: Yes
The resolution for your issue:: Neutral
Comments:: test comments
The technical skills/knowledge of the support team member:: Neutral
Would you recommend the Service Desk to other users?: Yes
Thinking of the method of contact selected above, how satisfied were you?: Satisfied
The quality of service you received:: Neutral
Did the Service Desk meet your expectations?: Yes
Was the issue completely resolved before the incident was closed?: Yes




It's not beautiful, but it works - feel free to tweak it for your needs.


I ran this code and thats seriously helpful



but i need only one field's response. here thats highlighted



find_real_file.png


In the mailscript, I'd add a line like the one below right before the gr.query():


gr.addQuery("metric", metric-name-you-want-printed);



That should limit the printing to whatever metric you need.


I too have implemented this however I get an email for each question in the survey rather than just a single email - all the email's have all the questions and answers.



Any thoughts why?



My notification is below:-



Table: Metric Result (asmt_metric_result)


Send On: Insert


Message:


${user.first_name} ${user.last_name} has completed the Service Satisfaction survey.


The survey was triggered by the resolution of ${instance.trigger_id.URI_REF}.   You can get hold of ${user.first_name} at ${user.email} or ${user.phone}.


Here are ${user.first_name}'s answers:



${mail_script:survey_results}



Mail Script:


template.print("<p></p>Results:<br />");


var gr = new GlideRecord("asmt_metric_result");


gr.addQuery("instance", current.instance);


gr.query();



while(gr.next()) {


  template.print(gr.metric.getDisplayValue() + ":   " +gr.string_value + "<br />");


}



Many thanks