Notifications

264 views

The valid_to field on the kb_knowledge (and the article template tables) indicates the date until which the article is valid. The default expiry date for KB Articles is set to 01/01/2020 as a result article will expire on this date and will not be searchable.

This is documented in Problem PRB1353174. The following changes are introduced in London Patch 10 (LP10), Madrid Patch 7 (MP7), New York Patch 1 Hot Fix 1,  New York Patch 2 (NP2) onwards,

For Existing Articles

  • A fix script to change valid_to of existing articles from 01/01/2020 to 01/01/2100.
  • This fix script will update only those articles which have valid_to="01/01/2020".
  • This fix script will run only the first time customer upgrades to any of the above mentioned or later patches.

For New Articles

  • The default value of the knowledge article valid_to field is changed to 01/01/2100 if and only if the default value has not been customized to a date other than what is shipped by ServiceNow in the base product.
  • Any new article created after upgrading to the above-mentioned patches or later will default valid_to to 01/01/2100.

From New York onwards

  • Users can configure the default number of days an article is valid from the date of creation at each knowledge base level.
  • For newly created articles, valid_to value is defaulted based on the validity configured at the knowledge base level.
  • If validity is not configured at the knowledge base level then
    • valid_to value of the newly created article defaults to 01/01/2100.
    • valid_to value of the new version of the article defaults to 01/01/2100 while checking out an existing article (when article versioning is enabled)

Please Note: If you have any customization around valid to date this change will not override the customization:

  • Fix will not update any article where the author has explicitly set the valid_to date on the article to be something other than 01/01/2020.
  • Fix will not update the default value of the valid_to field if it has been customized to something other than the default shipped in Base Code.

 

Recommendation

Upgrade to Fix targets

We recommend you upgrade to a Fixed version of the problem PRB1353174, before 01/01/2020. Check Known Error Article KB0781937 for more details.

Workaround

If you cannot upgrade to a fixed version, please run the script on your instance as an Admin to fix the default date at your earliest convenience.  

(function() {
var results = {
ArticleUpdate: {},
FixDefaultValue: {}
};
function updateArticles() {
var dbu = new GlideDBUpdate("kb_knowledge");
var dbq = new GlideDBQuery('kb_knowledge');
try {
dbq.addQuery('valid_to', '=', '2020-01-01');
dbu.setQuery(dbq);
dbu.setMultiple(true);
dbu.setValue('valid_to', '2100-01-01');
dbu.execute();
results.ArticleUpdate.Trigger = 'Success: Impacted Knowledge articles are Updated';
results.ArticleUpdate.Outcome = 'Success';
} catch (err) {
results.ArticleUpdate.Trigger = 'Error: Error Occured while updating knowledge articles, Check again later';
results.ArticleUpdate.Outcome = 'Error';
} finally {
dbu.close();
dbq.close();
}
}
function fixDefaultValue() {
var dictGR = new GlideRecord("sys_dictionary");
dictGR.addQuery("name", "kb_knowledge");
dictGR.addQuery("element", "valid_to");
dictGR.setWorkflow(false);
dictGR.query();
if (dictGR.next() && dictGR.default_value == "javascript:var d = new GlideDate(); d.setValue('2020-01-01'); d.getDisplayValue();") {
dictGR.use_dynamic_default = false;
dictGR.dynamic_default_value = '';
dictGR.default_value = "javascript:var d = new GlideDate(); d.setValue('2100-01-01'); d.getDisplayValue();";
dictGR.update();
results.FixDefaultValue.Trigger = 'Success: Dictionary record updated successfully';
results.FixDefaultValue.Outcome = 'Success';
} else {
results.FixDefaultValue.Trigger = 'Skipped: Default value for valid_to is not 2020-01-01';
results.FixDefaultValue.Outcome = 'Skipped';
}
}
updateArticles();
fixDefaultValue();
gs.print(new JSON().encode(results));
}());

Running this script will also do the same changes as fix targets

For Existing Articles

  • Will change valid_to of existing articles from 01/01/2020 to 01/01/2100.
  • Will update only those articles which have valid_to="01/01/2020"

For New Articles:

  • The default value of the knowledge article valid_to field is changed to 01/01/2100 if and only if the default value has not been customized to a date other than what is shipped by ServiceNow in the base product.
  • Any new article created after upgrading to the above-mentioned patches or later will default valid_to to 01/01/2100.
Note iconNote: This script will skip if you have any customizations around the knowledge article Valid to field.
Keep in mind that, when you choose to run the script if you can't upgrade, you are making a customization in your dictionary record.

 

Additional Information

 

FAQ

Q: Will this affect sub-prod instances, prod instances, or both?

A: Mainly Prod where end-user try to search for knowledge articles

 

Q: Should I do anything if I have already customized Valid To date on my instance?

A: This script or fix will skip if you have any customizations around Valid to field. Please ignore this if you have already updated the valid to date in your instance.

 

Q: How can I check the impacted records?

A: Check the default value of the dictionary record where table = kb_knowledge and Column name = valid_to. Also, look for knowledge article Valid To date.

If it's 01/01/2020, upgrade to Fixed Targets or running script will help.

 

Q: Will this workaround activity cause any downtime?

A: No, but we recommend to test it in sub prod and run it in prod during off-hours.

 

Q. Who can I contact if I have identified an issue?

A. Please contact the ServiceNow Technical Support Team. You can find contact information for your region at http://www.servicenow.com/support/contact-support.html.

Article Information

Last Updated:2019-11-27 02:50:58
Published:2019-11-27