- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 12:55 PM
Hi All,
Few days back all the articles published 200 + were visible for end users however now it only shows a bunch of attachments.
I figured somehow all the articles published now has Display Attachments as "False" and Attachment Link set as "True"
Is there a way to change all of it without having it to do one by one and going forward how do i ensure this does not happen
Regards,
Vidhukesh
Solved! Go to Solution.
- Labels:
-
Knowledge Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 01:15 PM
Without knowing how it happened, there's really no good recommendation that could be offered about ensuring it doesn't happen again.
If you're sure that the fix is to change those 2 field values, you can run a background script from the 'Scripts -> Background' module in your left nav to update a group of records without touching anything else or running scripts/workflows. Here's a sample script. It finds all KB articles updated in the last 7 days where 'Display Attachments' is 'False' and 'Attachment Link' is 'True'. Then it changes 'Display Attachments' to 'True' and 'Attachment Link' to 'False'.
// Query for all KB articles updated in the last 7 days where 'direct=true' and 'display_attachments=false'
var kb = new GlideRecord('kb_knowledge');
kb.addEncodedQuery('sys_updated_onONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()^direct=true^display_attachments=false');
kb.query();
gs.print(kb.getRowCount());
/*while (kb.next()) {
// Flip the 'direct' and 'display_attachments' fields
kb.direct = false;
kb.display_attachments = true;
kb.autoSysFields(false);
kb.setWorkflow(false);
kb.update();
}*/
Note that the script has the actual update of the records commented out. You'll want to run it one time first like that so that you can see how many records will be updated (using the 'kb.getRowCount' line) and make sure that matches what you expect to see. Once you get the correct number of records you should be safe to un-comment the while loop and run the fix script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 02:15 PM
If you've got deleted fields and missing dictionary entries you'll need to work with ServiceNow support.
If my original script solved the question you posted originally please mark that answer as correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2018 03:44 PM
I Figured it out its fixed now thanks Mark