RSolberg
RSolberg

Reputation: 26972

MultiValue Parameter

I'm working on a web application that renders a reporting services report as a PDF and one of my requirements is to allow for multiple locations to be included on the same report. To handle this, I have created a multi-value report parameter which seems to do the trick when using the RS UI, etc. But, I am using the webservice for reporting services and cannot for the life of me figure out how to set the value of the parameter to be identified as having multiple values.

I've tried simply setting it as "LOC1,LOC2", but that is being picked up as a single value. I have also tried "LOC1" + System.Environment.NewLine + "Loc2".

Upvotes: 2

Views: 1452

Answers (2)

Zack
Zack

Reputation:

Figured it out, you have to each value separately under the same name, snippet:

        //Register parameters
    ArrayList<ParameterValue> parmValues;

    for(Map.Entry<String,String> entry:reportParams.entrySet()) { 
        //is it multi-value?
        if(entry.getValue().contains(",")) {
            //yes, add multiple ParameterValues under the same name 
            //  with each different value
            for(String mval:entry.getValue().split(",")) {
                ParameterValue pv = new ParameterValue();
                pv.setName(entry.getKey());
                pv.setValue(mval.trim());
                parmValues.add(pv);
            }
        } else {
            //no, just a single value
            ParameterValue pv = new ParameterValue();
            pv.setName(entry.getKey());
            pv.setValue(entry.getValue());
            parmValues.add(pv);
        }
    }

Upvotes: 1

notnot
notnot

Reputation: 4642

You can send it through as a comma-delimited string if you're willing to parse it on the other end. A lot of languages have a String.Split(",") style method you can use for that.

Either that, or you can construct an array (or list, or collection) and pass that through as the parameter, though this would involve changing the contract on the webservice method.

Upvotes: 1

Related Questions