Select future days and times

Curious the community's ideas for the following. I have a form for scheduling customer call backs. The user needs to select a future date and time in 30 minute increments. However, the times available are different depending on the day of the week:

  • Monday - Thursday: 9:00am – 6:30pm
  • Friday: 9:00am – 5:30pm
  • Saturday: 10:00am – 1:30pm

I want days and times that are NOT within the above bullet points to not be options the user can select.

Go!

Here's one potential way to do it:

{formmenu: Monday; Tuesday; Wednesday; Thursday; Friday; Saturday; name=day}{if: day<>"Friday" AND day<>"Saturday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5, 6]}{elseif: day="Friday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5]}{elseif: day="Saturday"}{availablehours=[10, 11, 12, 1]}{endif}

{formmenu: name=hour; values={=availablehours}; cols=5}:{formmenu: 00; 30; name=minutes; cols=5}{if: hour=9 or hour=10 or hour=11}a.m.{else}p.m.{endif}{if: not contains(availablehours, hour)}{hour=10}{endif}

Basically the day dropdown determines what the available hours to select from are in the next menu.

There's one potential scenario that I also had to account for: let's say someone selects 6pm on Monday, which is acceptable. Then without changing the 6, they change it to Saturday which is an invalid entry -- by default, the 6 selection for the hour would stay there.

So, there's an extra {if} at the end that accounts for that and, if an invalid combination happens as a result of that, it changes the hour back to 10am automatically (since 10am is acceptable for all dates).

2 Likes

You my friend - are a LEGEND! Thank you so much!! Next time I make it out to WA, :beers: are on me!

Now I need to adapt this to allow for the input to be the date field date chooser!

Try this out. I also updated it to include a blocking error if a Sunday is selected.

{formdate: YYYY-MM-DD; name=date}{day={time: dddd; at={=date}}}

{if: day<>"Friday" AND day<>"Saturday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5, 6]}{elseif: day="Friday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5]}{elseif: day="Saturday"}{availablehours=[10, 11, 12, 1]}{endif}

{if: day="Sunday"}{error: You cannot select days that fall on Sunday; block=yes}{else}{formmenu: name=hour; values={=availablehours}; cols=5}:{formmenu: 00; 30; name=minutes; cols=5}{if: hour=9 or hour=10 or hour=11}a.m.{else}p.m.{endif}{if: not contains(availablehours, hour)}{hour=10}{endif}{endif}

1 Like

Thinking about taking this a step further. For the call back time, it's a window that it being requested to see in the task subject. So if the user selects 11:00am, the output actually be 11:00am - 12:00pm. Now, I can do this all day with time shifting commands, but these lists are not in time format. Thoughts?

How about this? Only thing I can see making this potentially not perfect would be if the times you originally outlined are the maximum possible. That is, if Friday at 5:30 is the latest end time and that selecting 5:30 shouldn't set it to 5:30-630.

{formdate: YYYY-MM-DD; name=date}{day={time: dddd; at={=date}}}

{if: day<>"Friday" AND day<>"Saturday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5, 6]}{elseif: day="Friday"}{availablehours=[9, 10, 11, 12, 1, 2, 3, 4, 5]}{elseif: day="Saturday"}{availablehours=[10, 11, 12, 1]}{endif}

{if: day="Sunday"}{error: You cannot select days that fall on Sunday; block=yes}{else}Callback time: Between {formmenu: name=hour; values={=availablehours}; cols=5}:{formmenu: 00; 30; name=minutes; cols=5}{if: hour=9 or hour=10 or hour=11}a.m.{else}p.m.{endif} and {end=hour+1}{endhour={time: h; at={=end}; pattern=k}}{=endhour}:{=minutes}{if: end>11 or end<9}pm{else}am{endif}{if: not contains(availablehours, hour)}{hour=10}{endif}{endif}

1 Like

Hey now that works very well! I've been messing with this since last night, trying to make the call back window 30 minutes instead of an hour. Cannot seem to get it right though. I tried manipulating both variables but still throwing a pattern error. I'll keep trying. Open to ideas too! Thank you Andrew!

Actually, I think I am over-complicating the solution. It really might be as simple as this:

{note: preview=no}Variables:
{day={time: dddd; at={=date}}}
{if: day<>"Friday" AND day<>"Saturday"}{availablehours=["9:00am - 9:30am",
"9:30am - 10:00am",
"10:00am - 10:30am",
"10:30am - 11:00am",
"11:00am - 11:30am",
"11:30am - 12:00pm",
"12:00pm - 12:30pm",
"12:30pm - 1:00pm", "1:00pm - 1:30pm",
"1:30pm - 2:00pm",
"2:00pm - 2:30pm",
"2:30pm - 3:00pm",
"3:00pm - 3:30pm",
"3:30pm - 4:00pm",
"4:00pm - 4:30pm",
"4:30pm - 5:00pm",
"5:00pm - 5:30pm",
"5:30pm - 6:00pm",
"6:00pm - 6:30pm",
"6:30pm - 7:00pm",
"7:00pm - 7:30pm"]}{endif}
{if: day="Friday"}{availablehours=["9:00am - 9:30am",
"9:30am - 10:00am",
"10:00am - 10:30am",
"10:30am - 11:00am",
"11:00am - 11:30am",
"11:30am - 12:00pm",
"12:00pm - 12:30pm",
"12:30pm - 1:00pm", "1:00pm - 1:30pm",
"1:30pm - 2:00pm",
"2:00pm - 2:30pm",
"2:30pm - 3:00pm",
"3:00pm - 3:30pm",
"3:30pm - 4:00pm",
"4:00pm - 4:30pm",
"4:30pm - 5:00pm",
"5:00pm - 5:30pm"]}{endif}
{if: day="Saturday"}{availablehours=["10:00am - 10:30am",
"10:30am - 11:00am",
"11:00am - 11:30am",
"11:30am - 12:00pm",
"12:00pm - 12:30pm",
"12:30pm - 1:00pm", "1:00pm - 1:30pm",
"1:30pm - 2:00pm"]}{endif}
{if: day="Sunday"}{availablehours=["Not Available"]}{endif}
{endnote: trim=yes}

Select a Callback Date:
{formdate: MM/DD/YYYY; name=date}{if: day="Sunday"}
{error: Callback Appointments Not Available On Sundays!; block=yes}{endif}

Select a window of time:
{formmenu: name=time; values={=availablehours}; cols=20}

Callback window scheduled for:
{=day} from {=time}

However, the lists overlap when selecting a day with a different range of available times to choose from.

However, the lists overlap when selecting a day with a different range of available times to choose from

Yep, I had to accommodate for that in my original example (e.g. choosing 6 on Monday was an acceptable time, but changing the date to Saturday kept the 6 hour selected, which wasn't acceptable).

This will make it so that if that happens, it defaults the time selector back to the earliest available time. The user will still need to select a new time, but at least it makes it so that they're not able to select a combination that doesn't exist.

{if: not includes(availablehours, time)}{time=availablehours[1]}{endif}

Since that doesn't generate any text or appear in the final result it can go anywhere, but I put that right next to the time dropdown in my testing snippet

THATS IT!!! That was the magic! Thank you Andrew. I really learned a lot through this exercise!