
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 07:30 AM
I have a need by our customer to update the Valid To date in KB articles by 1 year every time that KB article is updated.
So it should be looking at the updated (sys_updated_on) field and making the Valid To date (valid_to) 1 year from that date.
Should this best be handled thru a business rule.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 09:44 AM
Karen,
If you are on eureka, copy this script
setValidTo();
function setValidTo(){
var gr= new GlideDateTime(current.sys_updated_on.getDisplayValue());
gr.addYears(1);
current.valid_to=gr.getDate();
}
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 07:31 AM
Hi Karen,
A business rule would do this nicely. See the addYears() method here.
GlideDateTime - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 07:38 AM
Thank you I will let you know how this works out for me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 08:59 AM
Karen,
As chuck said, write a before business rule
when: before insert and update
script: add this script inside the onBefore function
var gr= new GlideDateTime(current.sys_updated_on.getDisplayValue());
gr.addYears(1);
current.valid_to=gr.getDate();
Thanks,
Abhinay
PS: Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 06:41 AM