Adding check-date fields to dialogs

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

 

 

When adding fields to Dialogs through Advanced Customizations, much of the expression work is done for you using the "Quick-Add Fields" function.  However you'll notice that when adding date fields, this shortcut function only adds it as a simple date control and not a "check-date" control (as seen for fields like Blocked-To" and "Paid Thru".  If you want a date field that can be "blank" instead of always having a date in it, you need to use a date control with a checkbox.

 

This example shows how to convert a simple date control to a check-date control.  

 

The example below assumes you have a field called "Cust_User_Date" that you're adding to the dialog, and the field name is "Date" so that the resulting date selection control is called "Date Input" (you'll need to change these in your expressions as needed for your names, of course).  

 

After using Quick-Add to add your date field, edit the "Date selection" element that's automatically added and follow these steps to make it a check-date field:

 

1. Change the Control Type to "Date selection with a checkbox".

 

2. Change the Initialize expression so that it sets the checkbox according to whether the field is blank or not.  For instance:

 

IIFQ(FieldIsBlank(ThisCust(),"Cust_User_Date"), 'DlgSetUserCtrlDateCheck("Date Input", .F.)', 'DlgSetUserCtrlDate("Date Input", FieldDate(ThisCust(),"Cust_User_Date"))')

 

3. Change the OK/Save expression to set the field to blank if the box is not checked:

 

IIFQ(DlgGetUserCtrlDateCheck("Date Input")=.F., 'SetFieldBlank(ThisCust(), "Cust_User_Date")', 'SetFieldDate(ThisCust(), "Cust_User_Date", DlgGetUserCtrlDate("Date Input"))')

 

That's all there is to it, so Save the changes to the element.  Now it will act like other check-date controls and allow the field to be blank (no date set) when the checkbox is not checked.

 

 


Page URL https://CampgroundMaster.com/news/addingdate-checkfieldstodi.html

Campground Master Home