- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2016 07:32 AM
I have a date field on my time card form that is a "Week Starts on Date". This needs to be a Sunday however right now the end user can chose any date. What I want to do is to force them to use a Sunday. (It can be a Monday if necessary). If a user chooses a Tuesday I want the field to populate with the Sunday of that week and notify the users that we have done that. Any help is greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2016 06:50 AM
Thank you to all!
Here is the business rule I ended up putting in place - the is a before rule for insert and update:
var gdt = new GlideDateTime(current.week_starts_on);
if(gdt.getDayOfWeek()!=6){
//gs.addInfoMessage('Week Starts On Date Must Be a Sunday');
current.week_starts_on.setError('Week Starts On Date Must Be a Sunday');
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2016 01:25 PM
I also tried with just 'week_starts_on' but it did not work - also the { after the onSubmit seemed to be required for syntax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2016 01:48 PM
Ok sorry partly user error....I have created the Client Script and the Script include now. The warning flashes up on the screen but it still allows the time card to be submitted. The error flashed up and then disappered and brought me to the list of time cards with the new one there with the incorrect date.
How do I bring them back to the time card?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2016 04:26 AM
The return false part should stop the submission. Let me run some tests and see if I can get it to stop.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2016 07:20 AM
Thank you Mike - let me know how it goes!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2016 09:56 AM
Sorry that I'm late to this but I just worked through a very similar issue. You can avoid the loop by using a switch statement (switching based on day of week) and when you hit sunday in the switch do nothing...that gets you out of the loop. Make sense?