Is there a way to validate or limit dates and times in a DateTime user option within offering request form?

We have a requirement for a DateTime user option in a service offering. This field will be used to ask the requestor to pick a date and time for a meeting, but that time must be within Monday to Friday, 9am-3pm Eastern time. We would like to either limit the choices of the DateTime picker to within that time window, or use a validation business rule to display an error if they choose outside of that time window.

Has anyone managed to achieve this within SMAX?

  • Verified Answer

    +1  

    The DateTime widget doesn't allow you to restrict the selection.

    Regarding validation, there isn't a simple function to use, but I can think of two ways

    #1 - define a time period to match your schedule. Then use the working_hours.EffectiveDuration function with the time selected and the time selected + a small interval (of let's say 1 minute, or even less). If the value returned by the function is the same as your interval, you are inside the schedule, otherwise you are not.

    #2 - use a specific timestamp as reference of day - preferably a Monday. Then use the days function to get the number of days difference between your day and the reference, then use a modulo 7 ( value % 7) operator that allows you to get the offset of the day. For the time of the day, you need to parse the time using the format function and extract the hour part.

    Best regards,

    Brindusa

  • 0 in reply to   

    Thanks, Brindusa, this is an intriguing idea that I might explore. Currently, the client is ok with simply providing help text to guide the user that they should only enter a date within a particular hours of operation, but I'll keep this in mind if they find users are not following instruction.

    I think it will still be great if in the future there is an ability to control the date picker with rules, maybe I will submit an idea.