Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Email script - KB article into Assessment Instance notification

shane_davis
Tera Expert

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 />");

}

1 ACCEPTED SOLUTION

Ken_Michelson
Kilo Guru

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


View solution in original post

7 REPLIES 7

The site is asking me to log on.


yes that's my dev instance. it is the URL format that I was sharing


Duh!   I totally missed the point...     Thank you for your help.