Today's blog post was written by Aaron Robinson, Solutions Architect at Sonoma Partners.
In this example, we have a custom entity called Visits, which allow a user to create a Visit record (similar to an appointment), and set a scheduled date and time for the visit. The form also contains a start and end time for the visit, to be completed after the visit occurs. Here we have also setup some business rules to enforce some logic on the date and time that can be entered for the actual visit start and end time as such:
- Rule 1: If the schedule date and visit start both contains data, and the scheduled date is greater than the visit start, show an error message on the visit start field so the user can correct the time. Essentially, we are trying to enforce that a visit start time should always be equal or greater than the scheduled date and time.
- Rule 2: If the schedule date, visit start, and visit end all contain data, and the visit start is greater than the visit end, show an error message on the visit end field so the user can correct the time. Same premise as above, but now between the visit start and end time. Logically your end time should not come before your start time.
Makes sense, right? So, let’s take a look at using this logic in both the web and mobile app.
In the screen shot below, I can move the visit start time before and after the schedule date, and the Error Message shows appropriately. The same happens with the visit end time, regardless of the time I use.
In the mobile app, this appears to be the case as well. I move the date/time back and forth, and everything appears kosher.
However, something odd happens around the noon hour for the visit end time. In this example, I set the start time to 11:00am, and the end time to 11:59am. Supposing for a moment that I entered the visit end incorrectly, or I was setting it when the system clock time was actually 11:59am, I want to change the end time to 12:00pm. When I click into the field to edit the time and change the hour to 12, the error message is flagged on the visit end field as being less than the visit start.
Again, technically this is correct, because it’s now validating the time as 12:59 AM, as the rule fired right when I changed the hour. The problem here is that even if I change the AM to PM, the error message remains because the rule doesn’t appear to revalidate again. This was fairly easy to remedy as you could click out of the field and back in, or hit clear field and re-enter the time from scratch, but adds a couple of extra taps and it’s not exactly obvious to the average user.
This post first appeared on Sonoma Partners Microsoft CRM And Salesforce.com B, please read the originial post: here