- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 01:34 AM
Hello Guys,
I have created a table within System Definitions > Tables that I am using track the expiry of digital certificates used by my organisation.
Within my table I have a fields u_expiry_date which is populated with the date certificates expire, I have also created a second field called u_review_date which will contain a date we need to order a new certificate.
The review date needs to be 30 days before the expiry date, having done some research I believe I can achieve this automatically using a Function Field and I believe the code below should achieve what I'm looking for. The issue I am having is I am unsure how to amend the code so the date is taken from the u_expiry_date field rather than specified in the code below. Is anyone able to assist?
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gdt.addDaysUTC(-1);
gs.info(gdt.getDate());
Also once I have the code corrected could someone explain the expected behavior of this feature? Will a value be calculated when a new record is inserted automatically? will this update automatically if the date changes within the review field? Will I need a business rule to trigger these?
Thanks
Craig
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 03:54 AM
After Insert/update business rule.
condition: Expiry date changes.
SCRIPT:
var date = current.u_expiry_date;
var gdt = new GlideDateTime(date);
gdt.addDaysUTC(-30);
var reviewdate = gdt.getDate();
current.u_review_date = reviewdate;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 03:54 AM
After Insert/update business rule.
condition: Expiry date changes.
SCRIPT:
var date = current.u_expiry_date;
var gdt = new GlideDateTime(date);
gdt.addDaysUTC(-30);
var reviewdate = gdt.getDate();
current.u_review_date = reviewdate;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2022 08:02 AM
Thank you, worked perfectly.