- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 11:49 AM
Hi Team,
We have configured surveys in our dev system, the trigger condition is when Incident state changes to Closed. Ideally this should trigger the surveys and a record should be created in the 'assessment_instance' table. However I cant' see a record been created and if it gets created it is without a Trigger ID and Task id.
We are also sending the survey as a link in the Incident Closed notification. I'm sharing all the details of the configuration below, please help me understand how to populate the trigger id & task.
Trigger Condition
Notification Mail Script to generate the Survey Link
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var gr = new GlideRecord("asmt_assessment_instance");
gr.addEncodedQuery("state=ready^trigger_id=" + current.sys_id);
gr.query();
if (gr.next()) {
link = gs.getProperty('glide.servlet.uri') + "/esc?id=take_survey&instance_id=" + gr.sys_id;
} else
link = gs.getProperty('glide.servlet.uri') + "/esc?id=take_survey&type_id=b94dba50db4d41107820b7fb68961959";
var backgroundColor = 'background-color: #1da7bd;';
var border = 'border: 2px solid #1da7bd;';
var color = 'color: white;';
var fontSize = 'font-size: 16px;';
var fontFamily = 'font-family: arial, helvetica, sans-serif;';
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: 5px;';
template.print('<a href="' + link + '"');
template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);
template.print('">');
template.print("Take Survey");
template.print('</a>');
})(current, template, email, email_action, event);
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2022 08:14 AM
I was able to resolve this. There was no issues with above code. The Repeat interval in the above trigger condition was 30 days which was not allowing the system to send the survey again to the same user(since it was already sent & it will wait for another 30 days to send the survey) changing that to 1 minute for testing worked out fine. The task and trigger ID was also populated.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2022 02:49 AM
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2022 08:14 AM
I was able to resolve this. There was no issues with above code. The Repeat interval in the above trigger condition was 30 days which was not allowing the system to send the survey again to the same user(since it was already sent & it will wait for another 30 days to send the survey) changing that to 1 minute for testing worked out fine. The task and trigger ID was also populated.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
thanks, it finally worked.
I was in stress for 7 hours man and this solution finally helped me out