How to add survey link in notification servicenow

Roshini
Giga Guru

HI Team,

Am trying to send a survey via notification.
Survey is created when the state is moved to resolved.
the assessment instance for the respective survey is also getting created. But when am trying to get the link for survey via the email script, it is not getting attached to the email notfiication. Can I get a fix for this.
Email script is :
script name :- smiley_survey_link_click_2

gs.sleep(10);
    var survey_instance = new GlideRecord("asmt_assessment_instance");
    survey_instance.addQuery("metric_type", "sys_id of survey");
    survey_instance.addQuery("trigger_id", current.getUniqueValue());
    survey_instance.query();
    if (survey_instance.next()) {
        template.print('<a href="/survey?id=$url page$' + survey_instance.getUniqueValue() + '">Please take a moment to answer one question regarding your service experience.</a>');
    }

And in notification am giving 
${mail_script:smiley_survey_link_click_2}
1 ACCEPTED SOLUTION

Hi Mark,
Thanks for your reply, it was a typo error in my sys_id that am passing in the glide record. It got resolved once the correct sys_id was passed.

View solution in original post

2 REPLIES 2

Mark Manders
Mega Patron

OOB the URL is created like: 

url = instanceURL + '?uri=%2Fassessment_take2.do%3Fsysparm_assessable_type=' + type + '%26sysparm_assessable_sysid=' + instance;
 
What is the outcome of your script? To what URL is it pointing so we know where it isn't going as expected.

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,
Thanks for your reply, it was a typo error in my sys_id that am passing in the glide record. It got resolved once the correct sys_id was passed.