- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2014 06:44 AM
Hello,
We have upgraded our dev instance to Eureka from Berlin and so far only have had a few minor issues. One of which I can't seem to fix so I was hoping someone here would have an idea. One of our teams uses a template for Change Requests. In this template, they have always set the "planned start date" and "planned end date" using
javascript:gs.now()
In Berlin, this would actually set the date and time to the current day at midnight which they liked. I think it only did this because gs.now() is a date function, but the field is date/time so it would default to midnight. Since the upgrade to Berlin, if we use gs.now(), it defaults to GMT time. So it doesn't look like midnight even though it is. I've found that
javascript:Packages.com.glide.glideobject.GlideDateTime()
gets the current date/time and shows it for the current time zone. We could get used to this if we have to, but we would love to be able to set it to show at midnight again in the current time zone, not GMT.
The other issue is that since the upgrade, it doesn't allow both fields to be the same time. It won't let us submit the change because it's validating that the end date is AFTER the start date. Since they are both set the same in the template, it won't let us submit until we change the end date, even by a minute or two. I've tried to use the gs date functions available to calculate a few minutes from now but it seems that I cannot use any calculated date in the template. It just doesn't work. Even using something like
gs.minutesAgo(5)
doesn't return anything when in the template.
So I guess my question is, is there a way to use a template to fill in 'today at midnight' in the start field and then today at 12:01 in the end field using a template? The team that uses these templates would like to click as little as possible, hence using the templates to fill in the date/time.
Thanks!
Solved! Go to Solution.
- Labels:
-
Ask the Expert

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2014 08:48 AM
Hi Sam,
Try this for your start and end dates.
Start date = javascript: gs.endOfToday();
End date = javascript: var gdt = new GlideDateTime(gs.endOfToday()); gdt.addSeconds(1); gdt.getValue();
In my instance that gives me the following results when applying the template:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 12:38 PM - edited ‎06-05-2024 12:41 PM
Thank you for the insight on this one!
I was having a hard time finding this critical point that you bring up here:
At some point when updating templates various system objects became unavailable to "javascript:" style calls within templates.
We have a weekly change request template that we always create the week before and deploy at the same time on Wednesdays. Trying to use the GlideDateTime and GlideTime objects didn't work with javascript: calls on template fields, despite the working in other areas where the exact same server-side code would work to set the same Date/Time fields (e.g., Default Value on the Dictionary Entry).
What you listed above worked for me with the exception of plugging in for Wednesdays at a different time.
javascript: var d = new Date();
d.setDate(d.getDate() + (10 - d.getDay())); d.getFullYear() + '-' + (+d.getMonth() + 1) + '-' + d.getDate() + ' 22:00:00';
I wrote a script include for it, but obviously in my use case it won't work on templates (though it does work similarly in other contexts).
var getSNReleaseDateTime = Class.create();
getSNReleaseDateTime.prototype = {
initialize: function() {},
getUpcomingWednesdayStartDateTime: function() {
var todayDateTime = new GlideDateTime(gs.now());
var integerForToday = todayDateTime.getDayOfWeekUTC();
var adjustToUpcomingWednesday = 10 - integerForToday; //must be 10 in order to get next Wednesday based on getDayOfWeek method returning 1 through 7
todayDateTime.addDays(adjustToUpcomingWednesday);
todayDateTime.addSeconds(93600); //adjusts UST so that it will align to 22:00:00 EST
var UpcomingWeds = todayDateTime;
return UpcomingWeds;
},
getUpcomingWednesdayEndDateTime: function() {
var todayDateTime = new GlideDateTime(gs.now());
var integerForToday = todayDateTime.getDayOfWeekUTC();
var adjustToUpcomingWednesday = 10 - integerForToday; //must be 10 in order to get next Wednesday based on getDayOfWeek method returning 1 through 7
todayDateTime.addDays(adjustToUpcomingWednesday);
todayDateTime.addSeconds(97200); //adjusts UST so that it will align to 22:00:00 EST
var UpcomingWeds = todayDateTime;
return UpcomingWeds;
},
type: 'getSNReleaseDateTime'
};