The CreatorCon Call for Content is officially open! Get started here.

Knowledge Articles not visible for End Users on Portal just shows attachment

vidhukeshvimal
Kilo Contributor

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 

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

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.

View solution in original post

6 REPLIES 6

Mark Stanger
Giga Sage

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.

vidhukeshvimal
Kilo Contributor

Hi Mark thanks for the quick response can you also guide me on how to set a business rule that this is always checked before it is pushed to review and published state

That what is checked exactly?  I don't think you want to force all of your KB articles to meet these same conditions, do you?  You might actually want to have some articles with those conditions.

vidhukeshvimal
Kilo Contributor

There is one issue i see now that when i right click on Display attachments and click configure dictionary it shows "Record not found" did it delete that record? if yes how do i restore it back?