locked
SSRS Using ReportingService2010 to get report parameters and resolve dependencies programmatically - HELP! RRS feed

  • Question

  • User-331009151 posted

    Hi all, I have written a replacement for the report viewer web control that works extremely well but for one thing.

    In summary I am dynamically building an interface for the report filters and then pass in a collection of parameter names and selected values. For this example my UI consists of 3 multi-select dropdowns where the content of dropdown 2 depends on the selection in dropdown 1 and dropdown 3 depends on the selection in dropdown 2. When a value changes in dropdown 1 I make a postback passing the UI values in order to get the default values for dropdown 2 and of course the same process to populate dropdown 3 when the value changes in dropdown 2. With me so far?

    I am using ReportingService2010 and calling GetItemParameters, with the render option set to false, to get all of the parameter info that I need.

    client.GetItemParameters(criteria.Path + criteria.Report, null, false, null, null).ToList();

    I am then iterating through the returned parameters and building up a dictionary of parameter dependencies and values (values are extracted by parameter name from the passed in UI collection mentioned above).

    // Now check other dependencies
    if (param.Dependencies != null)
    {
        foreach (var d in param.Dependencies)
        {
            if (!dependencies.ContainsKey(d))
            {
                // Check if we a valid value in the response collection to be able to set the dependency value
                var response = criteria.Responses.FirstOrDefault(r => r.Title == d.ToString());
    
                if (response != null && !string.IsNullOrEmpty(response.Value))
                {
                    var paramDetail = unrenderedParameters.FirstOrDefault(p => p.Name == d);
    
                    switch (paramDetail.ParameterTypeName)
                    {
                        case "DateTime":
                            DateTime validDate = DateTime.ParseExact(response.Value, "d/M/yyyy", CultureInfo.InvariantCulture);
                            dependencies.Add(d, new ParameterValue() { Name = d, Label = d, Value = validDate.ToString("yyyy-MM-dd") });
                            break;
    
                        default:
                            dependencies.Add(d, new ParameterValue() { Name = d, Label = d, Value = response.Value.Trim() });
                            break;
                    }
                }
            }
        }
    }

    Once I have done I then again call GetItemParameters with the render option set to true and also pass in the dependency parameter and value collection in order to resolve the dependencies like so

    client.GetItemParameters(criteria.Path + criteria.Report, null, true, dependencies.Values.ToArray(), null).ToList();

    Now this is where I am hitting a problem. I would expect that after selecting a value in dropdown 1, setting render to true and passing the dependant values in a call to GetItemParameters that I would get the default values for dropdown 2 populated but I don't. The status for dropdown 2 is always 'HasOutstandingDependencies'. 

    I am assuming that I need to somehow loop through the parameters to resolve all dependencies but I cannot figure out what I would need to do any different to what I already am consider the dependant values are already being passed. Any ideas?

    Thursday, January 5, 2017 12:25 PM

Answers

All replies

  • User-2057865890 posted

    Hi Scout7,

    The status for dropdown 2 is always 'HasOutstandingDependencies'. 

    This generally occurs when the valid values or the default value of a parameter is query-based and dependencies exist that have not been submitted to the GetItemParameters method.

    var paramDetail = unrenderedParameters.FirstOrDefault(p => p.Name == d);
    if(paramDetail != null)
    {
    }
    else
    {
    }

    reference: https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.getitemparameters.aspx

    Best Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 6, 2017 8:46 AM
  • User-331009151 posted

    Thank you for your reply however your provided link does not clarify anything beyond what I already thought which is that I was already passing in the required dependency parameters and values? How does SSRS handle the values passed in via the GetItemParameters call? I was under the impression, perhaps wrongly, that SSRS will look at the parameters, see a dependency and then check if a value for the dependency has been passed in the call and render the default values? Is that not the case?

    Friday, January 6, 2017 9:41 AM