verifying required fields during update

hi all

I am building a booking app for a venue that is booked on daily basis.

The DB is simple where an Events table exists with rows for all the possible dates for the next few years.

Each row has a Status column with Enum of "Free" and "Booked". "Free" is the set on all rows initially.

4 additional columns of Start/End Date/Time were added so that I can use the Calendar View.

For booking a specific day, the user goes to the specific day using a calendar, finds the relevant day card, presses a "book" action that opens the edit form. 

After the form is submitted successfully, I use a bot/process to update the Status to "Booked" (I tried that "book" action would be Group of Actions of (edit + update  status to booked) but it didn't work). I don't want the user to manually set the status to Booked as he could forget to do so.

My question here is: how to verify the mandatory data is populated when the booking is done?

I believe I should use a "Required If" formula but since the Status will be changed to "Booked" only after form is submitted, I cannot rely on it.

Any idea or best practice in this case?

 

Solved Solved
0 6 205
1 ACCEPTED SOLUTION

I suspect there is another functional tidbit you are not aware of - the CONTEXT() function.  This allows you to control what expression is applied to a column based on the context of the view  e.g. which Form view the user is in.

In your use case, you can only Cancel something that has already been booked so that shouldn't even be an option unless the Status is already "Booked".

Therefore,  there are possibly two options for an "unbooked" row (unless of course you have other options not yet explained):

  • Edit the Event details
  • Book the Event

To be able to control the updating of the Status and especially returning the  row back to its original state if the user chooses to Cancel the booking,  I would create TWO separate Forms - one designed for editing the Event details and a second designed for booking the event.  The advantage is that each implies a specific work flow and allowing you to attach different set of actions on Form Saved AND if the user cancels, the row is returned to its original state - i.e. no edits applied.

For example, when a user selects your "Book" action from the calendar, you navigate them to the specific Booking Form view.  You then are free to use two options:

  1. use the CONTEXT() function on Status column's App Formula to change the Status to "Booked" only if the view = Booking Form View and Name column is not blank.
  2. Attach a Form Save action to the Booking Form View only that sets the status to "Booked".

The first option is best as it sends only a single row edit to the server.  The second option would send two edits.

I hope this helps get you over your hurdle.

In either case, if a user Cancels the Booking Form view, the row returns to its original state.

View solution in original post

6 REPLIES 6

Since you likely only want to be able to Save the Form once all of the necessary fields are completed AND then set the Status to Booked automatically, then you should be able to simply set the Status to "Booked" as an Initial value when the new Form is opened.  In the end this achieves the same result, is easier and requires only the row add instead of an add and then an edit - i.e. its more efficient.

If you have other Status' the row could be initially set to (e.g. maybe "Saved") then you would simply need to adjust the Initial Value expression to account for this.

Then you can set the "Required" flag, or if needed add a "Required If" expression to make sure the other fields are filled in. 

Hi there

Thank you for the reply.

Maybe I'm missing something...

The events are already created and have a status of Free.

The user is editing the existing events. So new form is not used at all.

Users are only updating events using actions.

 

No it is me who was missing something.   I was in a bit of a hurry and I missed the part where you are updating the Events row to "Booked".   I was thinking of a separate "Bookings" table.

So let me approach this correctly now.

Are you familiar with the Form Saved behavior on a Form?  It allows you to attach actions when the Form is Saved to apply other automatic updates.

Since you already are automatically setting the Status column,  it doesn't need to be part of the validation.  You should be able to assume the Status will get updated by your implementation.  If it doesn't then that's a bug .in your app.

Use the Required_If like you normally would for any Form editing a row.   You would then attach your action (or a grouped action) to the Form Saved Behavior of that Form to apply additional updates.

Screen Shot 2022-06-02 at 8.23.16 AM.png

 

 

Hi there

I wasn't aware of the Event Actions actually. Thank you so much for that. I will use it for setting the status instead of using a bot/process.

However, I think we might have missed the main point in the question.

Let's say that each "Event" has 2 columns: Status and Name

By Default: an Event has Status="Free" and Name is empty.

There are 2 main actions provided to the user.

1. Cancel Booking: Sets the status to Free and empties the Name column.

2. Book: this opens the edit form for the Event. i want the Name to be Mandatory at this point.

I can't it mark it required in the Table itself, as it should be empty when Status is "Free".

So I want to say : Required_IF [Status]="Booked", but... the validation will happen immediately when Save button is pressed but at that point of time Status is not yet "Booked", right?

 It's kind of chicken and egg situation...

I suspect there is another functional tidbit you are not aware of - the CONTEXT() function.  This allows you to control what expression is applied to a column based on the context of the view  e.g. which Form view the user is in.

In your use case, you can only Cancel something that has already been booked so that shouldn't even be an option unless the Status is already "Booked".

Therefore,  there are possibly two options for an "unbooked" row (unless of course you have other options not yet explained):

  • Edit the Event details
  • Book the Event

To be able to control the updating of the Status and especially returning the  row back to its original state if the user chooses to Cancel the booking,  I would create TWO separate Forms - one designed for editing the Event details and a second designed for booking the event.  The advantage is that each implies a specific work flow and allowing you to attach different set of actions on Form Saved AND if the user cancels, the row is returned to its original state - i.e. no edits applied.

For example, when a user selects your "Book" action from the calendar, you navigate them to the specific Booking Form view.  You then are free to use two options:

  1. use the CONTEXT() function on Status column's App Formula to change the Status to "Booked" only if the view = Booking Form View and Name column is not blank.
  2. Attach a Form Save action to the Booking Form View only that sets the status to "Booked".

The first option is best as it sends only a single row edit to the server.  The second option would send two edits.

I hope this helps get you over your hurdle.

In either case, if a user Cancels the Booking Form view, the row returns to its original state.

Thank you so much. I'm immensely grateful for your help 💮

Indeed, I wasn't aware of the CONTEXT function.

I used the 2nd option you mentioned and it seems to work perfectly.

Thanks a million!

 

Top Labels in this Space