- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 05:26 AM
Any solutions I could find on the internet have not worked.
I only get strange behavior and have to delete the variable and create again.
We have a date field on a catalog item.
The default date should be 4 business days in the future.
If anyone is currently doing this, please help.
We only use the portal UI.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 11:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 05:37 AM
I was able to do this by setting the default value on the variable to something like this:
javascript:addDays(4);
Then I wrote a script include to do this for me like this:
function addDays(numDays) {
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(numDays);
return gdt;
}
(date displayed on 2019-01-29)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 05:57 AM
This will only add 4 days to the date not 4 business days.
// 4 business days
// first day of week MONDAY
var gdt = new GlideDateTime();
var days_to_add = 4
var day_of_the_week = gdt.getDayOfWeekUTC(); //monday will be 0
if(day_of_the_week==2){days_to_add = 7};
if(day_of_the_week>=3){days_to_add = 6};
gdt.addDaysLocalTime(days_to_add);
gs.info(gdt.getDate())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 07:40 AM
Hi Stewe,
Thanks for the quick reply.
I'm having a bad week so any help I can get, I appreciate.
Can I do this via an on load catalog client script or as a script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 09:58 AM
This totally works, but I'm not sure how to get the results to display as the default value in my catalog forms date field. Either as default or onLoad.