Forcing How-heard to be filled in

Top  Previous  Next

A common request is to make sure the How-Heard field is filled in when making a reservation.  We've had an article before, in Newsletter #26, showing how to force a field to be filled in (in that case it was # Adults).  

 

Changing that to check for How-Heard is a simple matter, but because the field type is a drop-down instead of a text field, slightly different expressions must be used rather than just changing the field name.

 

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 How Heard field, showing an error message and preventing the reservation from being saved if How Heard 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 (assuming 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 How Heard 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(DlgGetDropListSelectedText(1084)),

    'Eval(MessageBox("How-found must be filled in",0,2), DlgSetFocusCtrl(1084), .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 "How Heard" 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 How Heard 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 How Heard field.  Once you're all finished, just Save everything and try it out. Remember that if you entered the condition shown in step 4, it will still allow How Heard to be blank unless you log in as a lower level operator.

 


Page URL http://CampgroundMaster.com/help/forcinghow-heardtobefilled.html

Campground Master Home