Business Rule Script to set Resolved Boolean in KM Article to True

Katie Boal
Tera Contributor

Hi there,

 

I'm looking to set the "resolved" boolean in Knowledge Feedback in KM Articles when retired to true, and add a little note in on the work notes too. I've tried the below script, but I'm worried I'm not getting the right GlideRecord. Wondering if others have any advise on how to fix this?

 

(function executeRule(current, previous /*null when async*/) {


// See STRY0405702- Resolve to set true to any false-resolve-flag feedback relating to the retired article
	
var myQuery1 = "stateNOT IN3^feedback.article.article_id=" + current.article_id;
//gs.log("Query = " + myQuery1, STRY0405702 business rule");
//gs.log("Sys ID of article = " + current.sys_id, STRY0405702 business rule");
var fbtGr = new GlideRecord('kb_knowledge_feedback');
fbtGr.addEncodedQuery(myQuery1);
fbtGr.query();
while (fbtGr.next()) {
//gs.log("Found knowledge feedback " + fbtGr.number, "STRY0405702 business rule");
// Set 'resolved' flag to 'true' and add some work notes to explain why
fbtGr.resolved = true;
fbtGr.work_notes = '***** This knowledge feedback was auto closed by a business rule that runs when the parent article has been retired *****';	
var fbtGr_sys_id = fbtGr.update();
if (fbtGr_sys_id != null) {
  gs.log("Closed knowledge feedback - " + fbtGr.number, "STRY0238699 business rule");
}
}

})(current, previous);

 

1 ACCEPTED SOLUTION

Got it. Your query looked like it was based on kb_feedback_task though. You can make these changes in your original code then:

  • The table you want to query is 'kb_feedback'
  • There is no state column on the feedback tale, so your query will just be like 

 

"article.article_id=" + current.article_id;​

 

View solution in original post

5 REPLIES 5

Hi Laszlo,

 

That's fantastic thank you - dumbly missed I'd left that in from my cheeky theft elsewhere.