Answered
I have a problem where the start time and end time for stoppages are to be entered into an app which records all data for a shift for a machine. The shifts are: 6 am to 2 pm, 2 pm to 10 pm and 10 pm to 6 am. There is a separate app for each shift.
I would like to ensure that the user cannot enter timings before the start of the shift, or after the end of the shift. For example, in the app for the 3rd shift, he should not be able to enter a start time of say 9 pm or enter an end time of say 7 am.
Can you provide this type of check, similar to what you have provided for number fields?
0
Comments
Please sign in to leave a comment.
Hi Narayan,
I'm thinking through a potential work-around for this, but had a question for you: in your App, it sounds like users are manually setting the time (instead of having it automatically captured at the time the page opens) - is that right? For your workflow, could users potentially open the App at the beginning of their shift and again at the end, or are they always going to be doing it after the fact? Just thinking about some options.
Thanks!
I wayyyy over-complicated this for a while, but our amazing Support Team Lead, Jacquie, set me straight on the work-around here. Here's the setup:
First, you need a dropdown field to indicate which shift you're in, first, second, or third.
Each shift will have it's own set of fields that conditionally appear just for that shift. So you'll have 3 sets of 6 fields (3 fields that relate to the start time and 3 fields that relate to the end time; I've done this all on one screen, but you could have conditional screens instead of conditional fields).
You'll need a time field for when the person is starting their shift. Here's what my condition looks like to have this field only show for first shift:
The next field I've called Fail - First Shift Start. This is a field set to not display on mobile, but be required. What this means is that if this field's conditions are met, it will exist but users will not be able to edit it, so they won't be able to proceed. The important part is the additional condition; this field is set to only appear if the First Shift Start field is LESS THAN 06:00 (so, before 6 am):
The purpose of the third field is to tell users what they're doing wrong so they can go and fix it. It's just a static text field with some instructions (something like: please go back and fix your shift start time). For this field, you want to set the conditions so that it only appears if your shift is First, your First Shift Start is less than 06:00 AND if your first shift start does not equal blank (that last bit will prevent it from showing up when users first see the start shift field):
Then you basically repeat that for your shift end, but with the fail condition activating on being greater than 14:00. Repeat that for each shift (with the adjusted hours) and users won't be able to submit without fixing their hours.
Here's a link to a quick video of all of this working on mobile: https://gocanvas.wistia.com/medias/wi30htn9zj.
This is a bit complex, so let me know if you have questions!
I tried this out, and it works great! I also very much liked the way you prevent the user from going ahead if there is a mistake - I can use that in many apps. Thanks for the support and the great ideas!
Glad this is going to work for you, Narayan! That hidden conditional required field is a handy trick for sure, and I recommend always having the static text to let people know what they've done wrong, otherwise they just can't keep going and don't know why.