- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 04:23 AM
Take me to the survey link should be redirected to service portal
Please guide me in this.
var html = new AssessmentUtils().getInstanceLinkHTML(current);
template.print(html);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 04:52 AM
Hello Shweta Kasbe,
if you have created a notification on asmt_assessment_instance table then you can use the below email script to redirce the user to take survey in portal:
In the url below script I have used /sp?id=take_survey where sp is default portal in my Personal Instance you need to replace that with your portal name
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var instanceName = gs.getProperty("instance_name");
var instanceURL = "https://" + instanceName + ".service-now.com/sp?id=take_survey&instance_id=" + current.getUniqueValue();
template.print('<a href="' + instanceURL + '">Click here to take Survey</a>');
})(current, template, email, email_action, event);
Please mark my respsone as helpful/correct, if it answer your question.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 04:52 AM
Hi Shweta,
It calls for script include AssessmentUtils() which has function: getInstanceLinkHTML()
This should ideally take you to portal. Can you check for line 827 or so. Something as below is what I could find.
var instanceURL = gs.getProperty("glide.servlet.uri");
var overrideURL = gs.getProperty("glide.email.override.url");
var url = "";
if(this.redirectToPortal() == 'true'){
if(asmtRec.allow_public)
url = instanceURL + this.defaultServicePortal + '?id=public_survey&instance_id='+instance;
else
url = instanceURL + this.defaultServicePortal + '?id=take_survey&instance_id='+instance;
}
See if it meets your need i.e. if the If-else condition are satisfied or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 04:52 AM
Hello Shweta Kasbe,
if you have created a notification on asmt_assessment_instance table then you can use the below email script to redirce the user to take survey in portal:
In the url below script I have used /sp?id=take_survey where sp is default portal in my Personal Instance you need to replace that with your portal name
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var instanceName = gs.getProperty("instance_name");
var instanceURL = "https://" + instanceName + ".service-now.com/sp?id=take_survey&instance_id=" + current.getUniqueValue();
template.print('<a href="' + instanceURL + '">Click here to take Survey</a>');
})(current, template, email, email_action, event);
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2022 04:57 AM
hello
i assume that your notification is on survey table which is why you are passing the current object to the script include and that script include function is returning the native view link
instead of using this script include just do this
var url = "<a href='your_portal_prefix?id=take_survey&instance_id='"+current.sys_id+">"+"click here to take the survey"+</a>;
template.print(url);
Hope this helps
please mark my answer correct if this helps you