- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2013 04:14 AM
Hi all,
I'm trying to produce an onChange client script to determine whether the date entered in the 'start_date' field on a Change_Request is before or after NEXT Thursday (relative to NOW).
I've been looking at the guidance here: http://wiki.servicenow.com/index.php?title=GlideDateTime#GlideDateTime.28.29 but I'm struggling to see how I can create a GlideDateTime object and set it to the newValue of the 'start_date' field. But I may be heading in the wrong direction with this... Any advice appreciated.
Regards
Jamsta.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2018 01:22 PM
For those not looking at current date and instead looking at a date field, I learned that you can use the getDayOfWeek Glide function to check against the current record (so you can use it in a business rule, or, in our case, a workflow). My script below checks to see if a start or end date/time for a change record is between Friday and Sunday, returning True (and sending the change for added review) if that is the case:
answer = isWeekend();
function isWeekend() {
var impstart = current.start_date.getGlideObject().getDayOfWeek();
var impend = current.end_date.getGlideObject().getDayOfWeek();
if (impstart >= 5 || impend >= 5) {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2013 10:32 AM
Thanks again Aaron. I've got plenty to play around with now!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2013 02:19 PM
Not a problem 🙂 Dates are tricky in any language and it's never fun converting between two different formats. Luckily with JavaScript it's been done half a million times before so there's no need to reinvent the wheel. Glad it helped but feel free to ask for ore help if you get stuck.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2015 12:41 PM
Did you ever have a solution to this? If so, I would be interested in finding out what you did.
Thanks!
A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 02:37 PM
Hi All,
I had a similar cause for this, using the cab_date field. With some help I managed to get this one sorted.
You can find the full Javascript and code as well as the journey we took here:
https://community.servicenow.com/thread/182149
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2015 09:47 AM
Thank you Rob,
This is a much more elegant solution than the one I eventually came up with.