Business rules
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 07:06 AM
I have a date field and took some date for suppose 1-8-2020
I want add 2 to this field so that it should return the date after dates
the out put should be 3-8-2023
Can any one help please
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 08:36 AM
I would look into using the GlideDateTime library. There are some functions in there, like "addDaysLocalTime(Number days)" or "addMonthsUTC(Number months)" that should fit your needs.
Here is an example Business Rule using GlideDateTime:
(function executeRule(current, previous /*null when async*/) {
var date = current.getValue('resolved_at'); // grab the Date/Time field value
var gdt = new GlideDateTime(date); // convert it to a GlideDateTime object
gdt.addMonthsUTC(2); // add your desired days/months/etc
current.resolved_at = gdt.toString(); // set the field value to your new Date/Time
})(current, previous);