- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 08:33 AM
I currently have a date variable with a default value set for 5 days past the day the request is submitted. However, we would like to set this as 5 business days to not include weekends. Is this possible? Below is the script we are currently using for the default value:
javascript: new GlideDateTime(gs.daysAgo(-5)).getDisplayValue();
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 11:46 AM
//Try this as the default value
javascript: var d5 = '';
var gdt = new GlideDateTime();
var d = 5;
if (gdt.getDayOfWeek() == 6) {
daysout = daysout + 2;
}
if (gdt.getDayOfWeek() == 7) {
d = d + 1;
}
d = d * -1;
d5 = new GlideDateTime(gs.daysAgo(d)).getDisplayValue();
d5;
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 08:45 AM
Honestly at this point why not set it for 7 days? Worst case your 5 days ends on Friday and you have a partial business day while it closes on Sunday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 08:49 AM
Unfortunately that is not the route the customers want to go.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 09:12 AM
//Untested code
//try something like
var gdt = new GlideDateTime();
var daysout = 5;
//if today is saturday
if(gdt.getDayOfWeek() == 6)
{
daysout = daysout + 2;
}
//if today is sunday
if(gdt.getDayOfWeek() == 7)
{
daysout = daysout + 1;
}
//calculate the days out
daysout = daysout *-1;
var days5out = new GlideDateTime(gs.daysAgo(daysout)).getDisplayValue();
gs.print(days5out);
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2019 11:19 AM
This does not appear to work when I set it as a default value, which is where the date will need to populate.