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.
setGetCustomerOrders
. In the Script Editor, choose the beforeOpen
event.//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 = SQL + params["rprmGetCustomers"].value[x]; } //close out the IN statement SQL = SQL + ")"; //set the queryText to our new modified query this.queryText = SQL;
Using the Event Handler, we now need to maintain only a single copy of our query. This works in both examples because a multiselect parameter is an array of objects. We need to iterate over this array and append the values.