- 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-14-2016 01:07 PM
Dates can be a bit of a pain, if you have users in different timezones. There are different functions to handle that.
I just thought of something else, what about weekends? If you want the message to come up on weekends as well it may be easier to create a schedule.
Then you can use the isInSchedule() function.
looking at this, with the time spanning 2 days (evening into morning), i would probably suggest going with the schedule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 01:48 PM
Thanks for the reply! This is the first time ive used schedules... so I may be doing something wrong. Please see what I have set-up below. No matter what time I set the schedule to be free the message after hours still shows.
Script within record producer:
var schedRec = new GlideRecord('cmn_schedule');
schedRec.get('name','Research Request');
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"); 20.}
------------------------
Screen shot of schedule:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 05:41 AM
Can you post a screenshot after selecting 'show scheduled' in related link?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 05:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 05:54 AM
Actually. Out of Box you should have an 8-5 weekdays schedule. (along with a version that accounts for weekeds and another for holidays)
I would use this one, and reverse the logic.
If it's inside the schedule - no message; if it's outside - message.