- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 07:34 AM
The notification "Notify attestation recipient" on the Assessment Instance [asmt_assessment_instance] table emails the recipients when an attestation is executed.
My goal is to have an email script which queries the Knowledge [kb_knowledge] table for a KB with the same short_description as the assessment's metric_type. Below is what I have in my email script. No matter what code I use, I either get ALL of the KBs or nothing. Any help will be appreciated! Thank you.
EMAIL SCRIPT:
template.print("<br />");
var gr = new GlideRecord("kb_knowledge");
gr.addQuery('short_description', current.sys_id);
gr.query();
while (gr.next()) {
var link = new GlideSubstituteURL().generateURL(gr, '');
var title = gr.number;
if (gr.short_description == metric_type.name) {
title+= " - " + gr.short_description;
}
var anchor = "<a href='" + link +"'>" + title + "</a>";
template.print(anchor + "<br />");
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 07:51 AM
Shane,
With just a basic look at your script, line 03 is querying for where short_description is a sys_id value. I would expect that to always return 0 records, however in many cases, a poorly written addQuery() command does not error out, but is just ignored. This is a common issue resulting in getting "all" records.
I also do not see "metric_type" defined anywhere. (line 08). This the if statement may always return false.
last, I am not sure if you need to encodeURIComponent or not on the link before using it in your anchor.
Hopefully these tips help.
-Ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 10:45 AM
The site is asking me to log on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 10:53 AM
yes that's my dev instance. it is the URL format that I was sharing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 10:54 AM
Duh! I totally missed the point... Thank you for your help.