
- 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-14-2016 06:50 AM
Karen,
I have tested this on my instance, it was working. Can you attach a snapshot of your BR
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:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 07:00 AM
Karen,
This script needs to be placed in an onBefore function that will be automatically created in the script section when you create a business rule.
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 07:04 AM
Hi,
//var domain = new GlideRecord('incident');
//domain.addQuery('number', 'INC0010055');
//domain.query();
//if (domain.next()) {
var some=domain.opened_at.getDisplayValue();
gs.print(some);
var gdt = new GlideDateTime(some);
gdt.addYears(1);
gs.print(gdt.getDate());
}
Try like above:
Modify the changes it worked fine for me:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 07:01 AM
Hi Karen,
Thanks for the screen shot. In your testing, did "flagged" change? If it did not, then the business rule will not run the script.