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 the beforeOpen event.
    Using the MultiSelect parameter in an Event Handler
  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 = SQL + params["rprmGetCustomers"].value[x];
    }
    //close out the IN statement
    SQL = SQL + ")";
    //set the queryText to our new modified query
    this.queryText = SQL;
    
  4. Save and preview the report.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset