Using the MultiSelect parameter in an Event Handler
When we run the previous report, we can select either a single or multiple customers, and it will filter down. Now, the drawback is that we have to maintain two copies of our query—one in the query editor under the dataset editor and the one in the Property Binding expression. We can accomplish the same thing if we use an Event Handler and have to maintain only a single copy.
1. Repeat steps 1-16 in the previous example.
2. Open the Script Editor, and using the Outline or the Data Explorer, select
setGetCustomerOrders
. In the Script Editor, choose thebeforeOpen
event.3. Use the following JavaScript for our Event Handler:
//get the original query from the edit dialog and append the IN statement SQL = this.queryText + " AND CUSTOMERS.CUSTOMERNUMBER in ("; //iterate over the multi-select parameter, and append the values to our query for (x = 0; x < params["rprmGetCustomers"].value.length; x++) { if (x > 0) { SQL = SQL + ", "; } SQL ...