glide record for querying knowledge base

josh_brostoff
Giga Contributor

I want to make a glide record query that querys a knowledge base and then sets all articles in it to "disable_commenting = true", however, my script isnt working.   What is wrong here?

//Query the LegalEase knowledge base and find records that have disable commenting set to false.   Update those records to make disable commenting true.

var true_commenting = new GlideRecord('kb_knowledge');

true_commenting.addQuery('kb_knowledge_base', 'LegalEase');

true_commenting.addQuery('disable_commenting', 'false');

true_commenting.query();

while (true_commenting.next()) {

  true_commenting.disable_commenting = 'true';

  true_commenting.update();

}

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Josh,



A couple tweaks (noted in the comments)



var true_commenting = new GlideRecord('kb_knowledge');


true_commenting.addQuery('kb_knowledge_base', 'SYS_ID_OF_LEGALEASE'); // Requires a SYS_ID, not a name


true_commenting.addQuery('disable_commenting', false); // true/false values don't need quotes, they are JavaScript keywords


true_commenting.query();


while (true_commenting.next()) {


  true_commenting.disable_commenting = true; // same as above


  true_commenting.update();


}


View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

Hi Josh,



A couple tweaks (noted in the comments)



var true_commenting = new GlideRecord('kb_knowledge');


true_commenting.addQuery('kb_knowledge_base', 'SYS_ID_OF_LEGALEASE'); // Requires a SYS_ID, not a name


true_commenting.addQuery('disable_commenting', false); // true/false values don't need quotes, they are JavaScript keywords


true_commenting.query();


while (true_commenting.next()) {


  true_commenting.disable_commenting = true; // same as above


  true_commenting.update();


}


Thanks, Chuck!