Change default value of "Valid to" on KB Article.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 06:24 AM - edited 01-23-2023 09:57 PM
Hey Developers,
While creating a new KB Article, "Valid to" default date is 1st Jan 2100.
Requirement : - I want to change it & keep it 3 months from the date of KB creation.
While Investigation I have found the Client script & Script Include. which set the values to fields but couldn't not find code of line which sets the date.
Client script = Change Default Article Validity Date
Script Include = KBAjax
Found these details from below article
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0777724
Default value of field is "javascript: current.kb_knowledge_base ? new global.KBCommon().getDefaultValidToDateFromCurrentDate(current.kb_knowledge_base) : '';".
When Client script is Inactive. No values are fetched for "Valid to". It's empty.
Please suggest how this can be achieved.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2023 06:50 AM
Hello,
KB means Knowledge Base.
Are you meaning a knowledge article? The default you mentioned is going to look at the Knowledge Base itself for the default date you have listed there, if none is supposed, then it'll default to 1st Jan 2100. Every knowledge base is different and it wouldn't be recommended to change the behavior for the whole platform for this one scenario (unless this scenario is going to apply for the entire platform).
With that said, you'd simply want to set the date 3 months ahead for new articles regardless of what the out of box default value script is going. You can accomplish this in client script by creating a higher order number client script and take today's date, add 3 months, then set the valid to field value to the result. You can also accomplish this in a before business rule as well and do it all server side (but for better user experience, the user seeing the value on the form as they're filling out the article would be better).
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
01-23-2023 09:57 PM
I'm taking about KB article.
Yes, I want to change it for whole Platform.
Reason,
1. Article isn't up-to-date.
2. Author quits company & article becomes orphan.
3. When started clean-up plenty of these articles are found & it's difficult to maintain.
Initially it should be 3 months from the date of Article creation.
Author will receive valid to date expiry email in 2nd month & he can update the valid to date.
In this case, At least he is visiting on his article 2nd time.
Can you please help me with the script.?
Thank you.