- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 01:52 AM
Hi Team ,
Need help with the mail script to redirect the user to the survey link .
https://<instance-name>.service-now.com/esc?id=take_survey&type_id=d241f419471b21100a2e3e58c26d4338
The link should be dynamic .
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
gs.log("current " + current.number, 'sys');
var surv = new GlideRecord('asmt_assessment_instance');
surv.addNotNullQuery('trigger_id');
surv.addQuery('trigger_id', current.sys_id);
surv.query();
surv.next();
gs.log("Incident from survey " + surv.number, 'sys');
var params = current.number + "," + surv.number;
var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
//var mail = gs.getProperty("instance_name") + "@service-now.com";
//var mail = "testgpt0070@gmail.com";
email.setSubject(subject);
template.print('<br/>In order to improve the quality of our service, we invite you to evaluate the overall processing of your file by clicking on one of the following emoticons:<br/><br/>');
template.print('<img src="verymad.png" width="51" height="52"/></a>');
template.print('<img src="mad.png" width="50" height="53"/></a>');
template.print('<img src="neutral.png" width="49" height="53"/></a>');
template.print('<img src="happy.png" width="50" height="53"/></a>');
template.print('<img src="veryhappy.png" width="50" height="53"/></a>')
Thanks in Advance
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:22 AM
My Bad,
Please try below.
The URL generated was not correct.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
gs.log("current " + current.number, 'sys');
var surv = new GlideRecord('asmt_assessment_instance');
surv.addNotNullQuery('trigger_id');
surv.addQuery('trigger_id', current.sys_id);
surv.query();
surv.next();
gs.log("Incident from survey " + surv.number, 'sys');
var params = current.number + "," + surv.number;
var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
//var mail = gs.getProperty("instance_name") + "@service-now.com";
//var mail = "testgpt0070@gmail.com";
email.setSubject(subject);
template.print('<br/>In order to improve the quality of our service, we invite you to evaluate the overall processing of your file by clicking on one of the following emoticons:<br/><br/>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="verymad.png" width="51" height="52"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="mad.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="neutral.png" width="49" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="happy.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="veryhappy.png" width="50" height="53"/></a>')
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:14 AM
hi @Anil Lande
After updating script , not working 😑
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
gs.log("current " + current.number, 'sys');
var surv = new GlideRecord('asmt_assessment_instance');
surv.addNotNullQuery('trigger_id');
surv.addQuery('trigger_id', current.sys_id);
surv.query();
surv.next();
gs.log("Incident from survey " + surv.number, 'sys');
var params = current.number + "," + surv.number;
var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
//var mail = gs.getProperty("instance_name") + "@service-now.com";
//var mail = "testgpt0070@gmail.com";
email.setSubject(subject);
template.print('<br/>In order to improve the quality of our service, we invite you to evaluate the overall processing of your file by clicking on one of the following emoticons:<br/><br/>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/' + current.getTableName() + '/' + current.sys_id + '"><img src="verymad.png" width="51" height="52"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/' + current.getTableName() + '/' + current.sys_id + '"><img src="mad.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/' + current.getTableName() + '/' + current.sys_id + '"><img src="neutral.png" width="49" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/' + current.getTableName() + '/' + current.sys_id + '"><img src="happy.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/' + current.getTableName() + '/' + current.sys_id + '"><img src="veryhappy.png" width="50" height="53"/></a>')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:22 AM
My Bad,
Please try below.
The URL generated was not correct.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
gs.log("current " + current.number, 'sys');
var surv = new GlideRecord('asmt_assessment_instance');
surv.addNotNullQuery('trigger_id');
surv.addQuery('trigger_id', current.sys_id);
surv.query();
surv.next();
gs.log("Incident from survey " + surv.number, 'sys');
var params = current.number + "," + surv.number;
var subject = "survey:" + surv.number + " " + " " + "incident:" + current.number + " ";
//var mail = gs.getProperty("instance_name") + "@service-now.com";
//var mail = "testgpt0070@gmail.com";
email.setSubject(subject);
template.print('<br/>In order to improve the quality of our service, we invite you to evaluate the overall processing of your file by clicking on one of the following emoticons:<br/><br/>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="verymad.png" width="51" height="52"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="mad.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="neutral.png" width="49" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="happy.png" width="50" height="53"/></a>');
template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '/esc?id=take_survey&type_id=' + surv.sys_id + '"><img src="veryhappy.png" width="50" height="53"/></a>')
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:29 AM
Hi @Anil Lande
Thanks once again , I have updated my script as per the above .
I don't know why it is like this can u please here .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:48 AM
Hi,
The incident survey you are trying to attempt is not was assigned to system admin.
Open the survey that is assigned to logged in user.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:16 AM
Is it working with correct user now?
Thanks
Anil Lande