- 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 11:05 AM
Yes, I was just going to say I tried this and got a good date.
javascript:var gdt = new GlideDateTime('');
var dc = new DurationCalculator();
dc.setSchedule('090eecae0a0a0b260077e1dfa71da828'); dc.setStartDateTime(gdt);
dc.calcDuration(4*9*3600);
var edt= new GlideDateTime(dc.getEndDateTime())
edt.getDate();
edt.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 11:07 AM
I cannot believe this is working !!!!
Thank you dvp.
I'm over joyed.
I know lots of others who would like to do this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 11:10 AM
You are welcome 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 11:13 AM
So happy !!!!
I hope you have a really good week now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 10:51 AM
Currently, I'm using this in the default field.
javascript:var d = new GlideDateTime(); d.setValue(gs.daysAgo(-5)); d.getDisplayValue();
This just adds 5 days to today's date, which works. But I would like to use 5 business days.
This script below doesn't work just putting into the default field unless I need to format it a certain way.
Same if I make a script include. Do I call the script include from the default field, or call the script include from catalog client script? I can't turn this into a script include as is, since those 2 "if" lines will error.
I can try the script you gave above in the default field if you think it will work.
// 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())