- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 10:36 AM
Is there a way to put a warning message on a record producer (Either when first going to the form or after submitting) that only shows up after a certain time?
I need to put a warning up that shows up only during the hours of 5 PM - 8 AM.
Thank You!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 01:29 PM
oops, i think i screwed you up earlier.
looking at the error it says that it doesn't recognize the function isInSchedule('string') - becasue that function requires a date object not a string. i told you getNow would be an object and that's where i messed you up.
put this back in
var schedTime = new GlideDateTime(gs.nowDateTime());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 06:04 AM
I changed my script to this :
gs.include("FormInfoHeader");
var fi = new FormInfoHeader();
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name','Workday 9:00 - 5:00');
var sched = new GlideSchedule(schedRec.sys_id);
var schedTime = new GlideDateTime(gs.nowDateTime());
gs.log('Time 1: ' + schedTime);
if (sched.isInSchedule(schedTime, 'US/Eastern')) {
gs.addInfoMessage("in hours ");
}
else {
gs.addInfoMessage("after hours");
}
and the schedule looks like this :
But I still get the after hours message right now and its after 9:00.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 07:30 AM
The code looks correct, but the server may be using GMT time. (what time does schedTime show in the log).
You may have to force the timezone onto the getnow time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 10:02 AM
When you say in the log... do you mean just any entry in the log? When I check the log the time shows East coast time. Or am I looking in the wrong place?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 10:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 11:01 AM
Awesome! That seems to be working (Will do further testing). I really appreciate it. Would there be any way to turn this into an on submit script instead of on load?