- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 02:55 AM
Hello,
This is probably really simple but wouldn't know how to script it.
To give you some background we have knowledge base articles which mention specific assignment groups but every now and again these assignment groups are renamed and as you can imagine could cause some confusion.
What I want to do if its possible is to run a background script on the knowledge base which searches the 'text' field, finds and replaces the old value with the new value.
Solved! Go to Solution.
- 1,318 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 05:53 AM
Hi Andrew,
you may try something like this (e.g. replace 'aaa' by 'bbb')
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('text','CONTAINS','aaa');
gr.query();
while(gr.next()) {
oldText = gr.getValue('text');
newText = oldText.replaceAll('aaa','bbb');
gr.text = newText;
gr.update();
}
It seems it is not breaking the approval process in my PDI but be cautions about your actual process. The KB may change the state from 'Published' which I believe is not wanted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2022 05:53 AM
Hi Andrew,
you may try something like this (e.g. replace 'aaa' by 'bbb')
var gr = new GlideRecord('kb_knowledge');
gr.addQuery('text','CONTAINS','aaa');
gr.query();
while(gr.next()) {
oldText = gr.getValue('text');
newText = oldText.replaceAll('aaa','bbb');
gr.text = newText;
gr.update();
}
It seems it is not breaking the approval process in my PDI but be cautions about your actual process. The KB may change the state from 'Published' which I believe is not wanted.