- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 10:30 AM
Hello Team,
I have requirements to update Published KB article automatically at pre-defined interval using script.
Basically I need to update the Article body field. (below) which contains HTML data.
Please advise,
Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 01:16 PM
Hi,
Ok. You can use GlideRecord to query and get the published article(s) as needed and then add your string to the "text" field and then update the record.
Let me know after attempting yourself if you need further assistance and if so, with what.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 12:11 PM
Sunny,
You may try using regular script to modify field ('text' column name for Article body)
var rec = new GlideRecord("kb_knowledge")
rec.addQuery('sys_id','<sys_ID>');
rec.query();
gs.info(rec.getRowCount());
if(rec.next()){
var result = rec.setValue(<New Value of Article Body >);
result.update();
}
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 01:16 PM
Hi,
Ok. You can use GlideRecord to query and get the published article(s) as needed and then add your string to the "text" field and then update the record.
Let me know after attempting yourself if you need further assistance and if so, with what.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2021 10:41 AM
Thanks Allen.
I was thinking, may be it is HTML we might have to do it different way.
Quick question, Would it matter if the article is published? (i.e. After the update, will it create new version or save it under same version).
Please advise.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 04:45 PM
Hi Allen,
How are you getting through the publish process? In our instance we are using instant publish/instant retire workflows and a standard update script won't seem to work. I tried setting the autosysfields and the workflow to false but it still doesn't seem to work. We are currently running Vancouver and here's a sample script I used:
function run() {
var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery('workflow_state=published^number=KB0010032');
gr.query();
var log = [];
while (gr.next()) {
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.ownership_group = 'sysid-goes-here';
gr.update();
log.push(gr.getDisplayValue());
}
return log;
}
run();