The Now Platform® Washington DC release is live. Watch now!
12-08-2020 10:51 AM
Hi
I have created a survey for evaluating our Service Desk Team in our dev environment on the incident table, which is triggered when an incident is resolved or closed. The survey is - published, active, and send notifications box is checked. I also have a test email address sending notifications and confirm all other notifications are being received e.g. when incident is resolved etc.
I have tested and I can see the survey instances, however it is not sending the notifications. I have checked the sent mail and there is nothing showing either... I am at a loss! Hoping someone can help me out.
Thanks
Mike
Solved! Go to Solution.
12-15-2020 07:49 AM
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var taskGr = new GlideRecord(current.trigger_table + '');
if(taskGr.get(current.trigger_id + '')) {
template.print('<div style="font-size:10pt; font-family: ' + gs.getProperty('redirect.font.family') + ';"><strong>' + taskGr.getClassDisplayValue() + ':</strong> ' + taskGr.number + '</p>');
if(JSUtil.notNil(taskGr.description))
template.print('<p><strong> Description:</strong> ' + taskGr.description + '</p>');
if(JSUtil.notNil(taskGr.close_notes))
template.print('<p><strong> Resolution notes:</strong> ' + taskGr.close_notes + '</p>');
}
//url creation
var base = gs.getProperty('glide.servlet.uri');
var processor = 'sp?id=take_survey&instance_id=';
var recordParm = current.sys_id + '';
var url = base + processor + recordParm;
//build button/hyperlink
template.print('<p><font face="helvetica">');
template.print('<a href="' + url + '"');
var backgroundColor = 'background-color: ' + gs.getProperty('redirect.background.color') + ';';
var border = 'border: ' + gs.getProperty('redirect.border.thickness') + ' ' + 'solid ' + gs.getProperty('redirect.border.color') + ';';
var color = 'color: ' + gs.getProperty('redirect.font.color') + ';';
var fontSize = 'font-size: ' + gs.getProperty('redirect.font.size') + ';';
var fontFamily = 'font-family: ' + gs.getProperty('redirect.font.family') + ';';
var textDecoration = 'text-decoration: none; border-radius: 3px;';
var webKitBorder = '-webkit-border-radius: 3px;';
var mozBorder = '-moz-border-radius: 3px;';
var display = 'display: inline-block;';
var padding = 'padding: ' + gs.getProperty('redirect.padding') + ';';
template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding + '"');
template.print('>');
template.print(gs.getMessage('Take me to my survey'));
template.print('</a>');
template.print('</font>');
//template.print('<br><br>');
template.print('<p> Thanks in advance for your time.');
template.print('<p> To view and/or complete any outstanding surveys, visit the ');
template.print('<a href=' + base + 'sp>Enterprise Services portal</a></p></div>');
})(current, template, email, email_action, event);
Sorry for the delay. Here's a mail script I wrote for that link:
12-08-2020 11:21 AM
At a quick glance of your Trigger Condition, is there an active notification for the insert of new surveys (against the asmt_assessment_instance table)? I am assuming the issue isn't that you're using the same caller and are hitting the 30 day repeat interval condition, and the caller you're testing with does have a valid email, and no email preferences to exclude receiving emails for surveys.
12-08-2020 02:09 PM
Thanks Ryan. No there isn't a notification set up against that table, as reading the documentation I wasn't aware I had to do one as I followed this example https://docs.servicenow.com/bundle/paris-servicenow-platform/page/administer/survey-administration/reference/r_TriggerConditionExample.html.
I have now set up a notification with "assigned to"(see below) and it is sending notifications based on insert of new survey. So how do I actually dynamically populate the survey or link to the survey in this notification?
12-15-2020 07:49 AM
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var taskGr = new GlideRecord(current.trigger_table + '');
if(taskGr.get(current.trigger_id + '')) {
template.print('<div style="font-size:10pt; font-family: ' + gs.getProperty('redirect.font.family') + ';"><strong>' + taskGr.getClassDisplayValue() + ':</strong> ' + taskGr.number + '</p>');
if(JSUtil.notNil(taskGr.description))
template.print('<p><strong> Description:</strong> ' + taskGr.description + '</p>');
if(JSUtil.notNil(taskGr.close_notes))
template.print('<p><strong> Resolution notes:</strong> ' + taskGr.close_notes + '</p>');
}
//url creation
var base = gs.getProperty('glide.servlet.uri');
var processor = 'sp?id=take_survey&instance_id=';
var recordParm = current.sys_id + '';
var url = base + processor + recordParm;
//build button/hyperlink
template.print('<p><font face="helvetica">');
template.print('<a href="' + url + '"');
var backgroundColor = 'background-color: ' + gs.getProperty('redirect.background.color') + ';';
var border = 'border: ' + gs.getProperty('redirect.border.thickness') + ' ' + 'solid ' + gs.getProperty('redirect.border.color') + ';';
var color = 'color: ' + gs.getProperty('redirect.font.color') + ';';
var fontSize = 'font-size: ' + gs.getProperty('redirect.font.size') + ';';
var fontFamily = 'font-family: ' + gs.getProperty('redirect.font.family') + ';';
var textDecoration = 'text-decoration: none; border-radius: 3px;';
var webKitBorder = '-webkit-border-radius: 3px;';
var mozBorder = '-moz-border-radius: 3px;';
var display = 'display: inline-block;';
var padding = 'padding: ' + gs.getProperty('redirect.padding') + ';';
template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding + '"');
template.print('>');
template.print(gs.getMessage('Take me to my survey'));
template.print('</a>');
template.print('</font>');
//template.print('<br><br>');
template.print('<p> Thanks in advance for your time.');
template.print('<p> To view and/or complete any outstanding surveys, visit the ');
template.print('<a href=' + base + 'sp>Enterprise Services portal</a></p></div>');
})(current, template, email, email_action, event);
Sorry for the delay. Here's a mail script I wrote for that link: