.
 

Y2.02K approaches… Thousands of Knowledge Articles are about to fall into the abyss!

June 29, 2019 9:30 am

Published by

When you create a new Knowledge Article the Valid To field defaults to 01-01-2020. What does this mean? If you or your customers have created Knowledge Articles and left the Valid To field with its default value, those articles will no longer be accessible in six months time.

Before we address this impending doom we need to ask: why are you leaving the Valid To date at its default value? Knowledge should be periodically reviewed to ensure it is still accurate and relevant, ideally we should be setting the Valid To field to a date relative to the publishing date, for example 6 months or 1 year from being published

Setting a relative Valid To date

An example of setting the Valid To field to 1 year after the creation of the article using a calculated value on the Valid To field

  1. Go to Knowledge > Articles> All
  2. Open any Knowledge Article
  3. Right click on the Valid To field, click on Configure Dictionary
  4. Complete the form
    • Dynamic Default: false
    • Calculated: true
    • Calculated value:
      (function calculatedFieldValue(current) {
      
        var validTo = new GlideDate();
        validTo.setValue(gs.yearsAgo(-1));
        return validTo.getValue();  
      
      })(current);

       

Fixing existing default values

We need to review the articles that are set to expire on 01-01-2020 and change the Valid To date of any articles that should continue to be available after that date

Report on existing articles with the default Valid To date

Review the articles that have been created with the default Valid To date.

Fixing existing articles with the default Valid To date

Run a background script to change the Valid To date of any articles that were created with the default value to another date in the future (in this example we set it to 01-01-2020)

var gd =new GlideDate();
gd.setValue('2021-01-01'); //set the new valid_to date value

var gr = new GlideRecord('kb_knowledge');
gr.addEncodedQuery("workflow_state=published^valid_toON2020-01-01@javascript:gs.dateGenerate('2020-01-01','start')@javascript:gs.dateGenerate('2020-01-01','end')");
gr.query();
while(gr.next()){
  gr.valid_to=gd.getValue();
  gr.update();
}

 

Conclusion

In six months time any articles that were created and left with the default value in Valid To will become unavailable. You and your customers need to review your Knowledge Bases to ensure that any articles that should still be available after 01-01-2020 have their Valid To values updated. Let’s make sure that 2020 gets off to a flying start!