Tips & Tricks - Conditional Display
In this post, you'll learn how to integrate a button into a custom table and use conditional display to show or hide it based on a date.
Create an Application
Create an application using the "Basic Application" template.
On the input page, an input field with the "Date & Time" control type is created. To do this, double-click Container 1—which also contains the "Title" input field—to open the zoom area.
You can find out how to create elements here.
Return to the workspace by clicking the corresponding tab next to the Zoom tab.
Then create a view page using the "New / View Page" option in the data group's context menu.
This view page, titled "Event Details," will later be incorporated into a customizable table. Create the two view fields "Date" and "Title," which will be linked to the data fields of the same name, and arrange them in a single row. In addition, a button labeled "Edit" is created. The input page can be set as the destination for the button.
Then enable the options for experts. Open the button's Properties dialog box and click "Options" on the "General" tab. Enable conditional display and open the Velocity Editor by clicking "
" and then "Edit Condition." Enter the following script there.
## Initialize CalHelper
$CalHelper.init($Request)
## Do not show button by default
#set($show_buttoncontrol5776AA58 = false)
## Get timezone of the current user
#set($TZ = $User.getTimeZone())
## Get current date
#set($Now = $CalHelper.getNowCalendar($TZ))
## Read value from data set (view control on page) within the table structure of the overview page
#set($To = $drRecord.getValueHolder("datecontrol2AEFE7BE").getValue())
## Comparison of the date values. Please note: getTime() has to be executed twice
## on CalenderObject to get ms value
#if($Now.getTime().getTime() < $To.getTime())
#set($show_buttoncontrol5776AA58 = true)
#end
Replace "buttoncontrol5776AA58" with the name of your button and "datecontrol2AEFE7BE" with the name of your "Date" view field. Both names can be found in the "Application Structure" section of the editor.
Then go to the "All Entries" page. Remove all elements located there and create a free-form table. Open the table's Properties dialog box. On the "Data" tab, include the "Appointment Details" view.
Add the "Entry" input page to the application menu by selecting "Properties" from the context menu of the application node, so that you can enter data records in the browser later.
Close the Properties dialog by clicking "OK" and save the application. Open the portal and the application in your browser.








