Scroll

Server Event: Pass multiple filter values in a parameter

This event allows you to pass a set of filter values in a parameter to an "IsOneOf" or "IsNotOneOf" report filter. This can lessen the number of parameters needed to filter reports dynamically in the API. Filter values are set in a string, and are separated by a delimiter character, such as a tilde (~).

Global Event: OnReportExecuteStart

Namespaces:

  • WebReports.Api.Common;
  • WebReports.Api.Reports

Usage

Parameter value (with ~ delimiter): "Buchanan~Davolio~Callahan"

IsOneOf filter value (not prompting): @ParameterName@

Code

string delim = "~";

foreach (Parameter param in sessionInfo.SetupData.Parameters)
{
  // inspect each filter to determine which have this parameter
  foreach (Filter filter in sessionInfo.Report.ExecFilters)
  {
    if (filter.Value == string.Format("@{0}@", param.Id))
      filter.DataValues.Clear(); // remove the parameter from the filter values array
    else
      continue;

    // get all the filter values by splitting the parameter string into its components
    string[] values = param.Value.Split(new string[] { delim }, StringSplitOptions.None);

    foreach (string value in values)
    {
      // add each part of the parameter as a separate value to the filter values collection
      filter.AddValue(value);
    }
  }
}
return null;

Hidden Article Information

Article Author
Exago Development
created 2017-06-27 15:02:32 UTC
updated 2017-06-27 15:14:25 UTC

Labels
filter, value, SAE, server event, events, example, parameter, param, isoneof, oneof,
Have more questions? Submit a request