Forcing Reservation fields to be filled in

Top  Previous  Next

DISCLAIMER: This article involves Advanced Customizations, which can be technically challenging to get working and is not part of standard support.  This is programming and must be done precisely or the results can be unpredictable.  This information is provided as a service for those who have the technical skills to work through it -- we cannot help you solve any issues with getting it working.  For more information about Advanced Customizations, see the full documentation:

https://campgroundmaster.com/help/overview32.html

 

 

Some users have asked if it's possible to force certain fields to be filled in, for instance to not allow a reservation be completed without the # Adults and # Children numbers filled in.  This is possible in version 4.0 through the Dialogs definitions.

 

1. The first step is to add a Dialog definition that's an Add-on to the New Reservation dialog.  Go to Maintenance / Advanced Customizations / Dialogs, and click "Add dialog definition".

 

Note: Only one Add-on definition can be active for a given dialog, so if you already had such a definition then you would just add elements on to the existing one instead of creating a new one here (in which case, skip to step 3).

 

2. Give it a name, such as "New Reservation add-on".  Then check the "Add-on" box and select "New Reservation" from the list.  We're not adding any new controls to it, so the Width and Height values can remain 0.

 

3. Now we need to add an action to the dialog that checks the # Adults field, showing an error message and preventing the reservation from being saved if # Adults is blank.  Click "Add Element", and for the element type select "Action on data saved".

 

4. We don't really need a Condition for this element (we always want it to force the field), though you might want to add a condition so that only non-administrators are restricted, for instance..  In that case you could put in the following Condition:

 

 CurrentOpLevel() < 5

 

5. Now for the Action expression, which will be executed when the reservation is saved (e.g. "Done", "Continue", or any other button clicked that would normally save the reservation).  We won't go into the design details, but it should be fairly self-explanatory if you look up the components in the Function Reference of the Advanced Customizations documentation.  Also note that we need the Control ID of the # Adults field, which can be looked up in the Dialog Control ID reference.  This can be found online here: http://campgroundmaster.com/help/basedialogs.html.

 

Enter this for the Action expression:

 

IIFQ( Empty(DlgGetCtrlText(1079)),

    'Eval(MessageBox("# Adults must be filled in",0,2), DlgSetFocusCtrl(1079), .F.)',

    '.T.')

 

A few notes about the expression:

- It's broken into 3 lines for readability here, but it must be continuous (no line breaks) when you enter it.

- IIFQ is used instead of IIF, because we don't want both of the result expressions to be evaluated (which would result in the error showing up no matter what).

- If the "Adults" field is empty, it does the Eval( ) function, else it simply returns True.

- The Eval function does 3 things in sequence: Shows the error message, sets the keyboard focus to the field (for convenience), and returns False to abort the saving process.

 

6. We also need to check both of the boxes -- "Execute the action before..." and "Abort the operation...".  Obviously we want to make sure this condition is met before actually saving the reservation, and if the # Adults is not filled in then we don't want to save the reservation yet.

 

7. Now just Save the element, and we're done with the customization for checking the # Adults field.  You can easily Copy the element to do the same check on the Children field (just change the Control ID to 1080, and change the error message text), or any other verifications you want to do.  Once you're all finished, just Save everything and try it out.

 


Page URL https://CampgroundMaster.com/news/forcingreservationfieldsto.html

Campground Master Home