The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mass Edit Knowledge Base Files

josephtucker
Giga Contributor

I have a large list of knowledge base files that require the same modification in each (appending something to an href tag).

Is there a way to mass edit this specific list?

1 ACCEPTED SOLUTION

BenPhillipsSNC
Kilo Guru

Hi Joseph,



The best way to do this would probably be to write a GlideRecord query to update your records. The Knowledge base's table name is "kb_knowledge". First you'd write a GlideRecord query that "grabs" all of your intended records, then search thru the "text" field using a pattern find/replace methodology such as a JavaScript Regex. Please review these articles:



wiki.servicenow.com/?title=GlideRecord


wiki.service-now.com/index.php?title=GlideRecord#Query_Methods



If you are on a version prior to Eureka Patch 5 you will need to use the ServiceNow Regex API:


http://wiki.servicenow.com/index.php?title=SNC_Regex_API



If after Eur Patch 5, just use standard JavaScript regex:


http://www.w3schools.com/jsref/jsref_obj_regexp.asp



An example would be something like:



var myKbs = new GlideRecord('kb_knowledge');


myKbs.addQuery('active',true);


myKbs.addQuery('sys_created_on', ">", "2014-01-19 04:05:00");


myKbs.query();


while (myKbs.next()) {


  //do something here possibly using a REGEX to find your "href=" string and append a string to it


  //update using myKbs.update();


}


View solution in original post

8 REPLIES 8

BenPhillipsSNC
Kilo Guru

Hi Joseph,



The best way to do this would probably be to write a GlideRecord query to update your records. The Knowledge base's table name is "kb_knowledge". First you'd write a GlideRecord query that "grabs" all of your intended records, then search thru the "text" field using a pattern find/replace methodology such as a JavaScript Regex. Please review these articles:



wiki.servicenow.com/?title=GlideRecord


wiki.service-now.com/index.php?title=GlideRecord#Query_Methods



If you are on a version prior to Eureka Patch 5 you will need to use the ServiceNow Regex API:


http://wiki.servicenow.com/index.php?title=SNC_Regex_API



If after Eur Patch 5, just use standard JavaScript regex:


http://www.w3schools.com/jsref/jsref_obj_regexp.asp



An example would be something like:



var myKbs = new GlideRecord('kb_knowledge');


myKbs.addQuery('active',true);


myKbs.addQuery('sys_created_on', ">", "2014-01-19 04:05:00");


myKbs.query();


while (myKbs.next()) {


  //do something here possibly using a REGEX to find your "href=" string and append a string to it


  //update using myKbs.update();


}


Does anyone have a fully working example? Even something simple like replacing "hello" with "bonjour" in all KB articles in a KB table would be a helpful start.

mbhmbhmbh
Tera Contributor

I realize this is a very old thread, but for what it's worth, I have confirmed via a  HI ticket that there is no other route than JS/RegEx. An enhancement has been submitted, but it couldn't hurt for others in need to also request this feature! 

We have the same need, also.

I'm new to this. How would I go about requesting the feature?