Scripting Example: The Period Case |
If you want to query data within a period of time, you can for example enter a search condition in a DATE field: >01-jan-2006 & <31-dec-2006 However, a more user-friendly way to let the end-user query data within a time period, is to define a VariableSetDataSource object with two variables that represents a period of time, with a from date and a to date. In two additional text fields, the user can then enter these dates. Suppose, the search group of an info page contains an S_BOOK_DATE field that is connected to a BOOK_DATE column of a RESERVATION table. To use variables to query data within a period of time:
The top of the object tree now looks like this:
Make sure this action is executed before the executeQuery action, by adjusting the Seqno property.
var bookDate,fromDate,toDate; bookDate=""; fromDate=getValue("period","fromDate"); toDate=getValue("period","toDate"); if(fromDate!="")bookDate=">"+fromDate; if(fromDate!="" && toDate!="")bookDate+="&"; if(toDate!="")bookDate+="<"+toDate; setSearchValue("RESERVATION","BOOK_DATE",bookDate)
NOTE: Leave the column control in Edit mode.
|