Examples of pre-query scripts

  1. The manipulation of the WHERE clause of a Search. The platform appends the result of this query to the result of the generated whereClause.

// check if whereClause already exists
if (whereClause.length() > 0) {
    // whereClause already exists. append AND or OR clause as required
    whereClause.append(" AND ");
}
// use bind variables. e.g. ? or :EVENT_STATUS
whereClause.append("x.EVENT_STATUS = ?");
// append the bind variable
params.add(101);

2. Advanced manipulation of the WHERE clause

String custNo = data.get("accountNumber");
// check if the custNo is entered by the user in the search region
if (custNo != null) {
    if (whereClause.length() > 0) {
        whereClause.append(" AND ");
    }
    if (custNo.indexOf("%") != -1) {
        // wildchar found, use LIKE instea
        whereClause.append("X.ACCOUNT_NUMBER LIKE ?");
    } else {
        whereClause.append("X.ACCOUNT_NUMBER = ?");
    }
    params.add(custNo);
}

3. Calling a PL/SQL procedure before executing the query

4. The manipulation of the ORDER BY clause of a search. The platform appends the result of this query to the result of the generated order by clause.

5. Replacing the FROM clause of a query

6. Manipulating the bind variable

7. Replacing the query with a custom query with UNIONs

8. Restricting blind query by appending the following code at the end of the pre-query script

9. Query allowed By default, all attributes are query allowed and the platform automatically generates whereClause when a user perform a search on an attribute. To programmatically control the whereClause, uncheck the Query Allowed property while defining the attribute properties to ignore those attributes while generating the whereClause.

10. Custom handling of grid filters

You can access the data related to the grid filters through FilterConfig object. You can usedata.getFilterConfigs() method to retrieve the list of FilterConfig.

11. Range query

By default, platform generates range search fields in a simple search panel for all date and number attributes. For custom search panel, while defining the attribute properties, you can define calculated from and to attributes with Select and Query Allowed unchecked. This will limit the range for search values.

12. Query by name

The following pre-query script shows a simple approach for performing search:

Last updated

Was this helpful?