rss scripting solution for show/hiding a deployed report parameter

  • Help. I have a master report with multiple linked reports where a parameter drives data security.  The master report is to be used by enterprise users who can view all data, they can select one or multiple "practices" via the practice_id parameter. Each practice has a linked report in a separate SSRS folder secured by using AD groups (there are a dozen or more practices), The practice report has the practice_id parameter defaulted and hidden, limiting their view of data.

    The problem I'm having is that sometimes when deploying a report revision to the master, the practice_id parmeter becomes unhidden or hidden. The enterprise users sometimes lose the ability to select the practice, the practice users sometimes gain the ability to select the practice.

    I'd like to write a script using the rs utility to programmatically set the hidden property to true or false based on the report / linked report.  Am I going about this the right way? I cannot find scripting samples.  I could probably write some SQL against the reporting services database, but that seems like a hack and is risky.

    Thanks,
    Myles

  • Myles Sigal - Wednesday, March 1, 2017 11:45 AM

    Help. I have a master report with multiple linked reports where a parameter drives data security.  The master report is to be used by enterprise users who can view all data, they can select one or multiple "practices" via the practice_id parameter. Each practice has a linked report in a separate SSRS folder secured by using AD groups (there are a dozen or more practices), The practice report has the practice_id parameter defaulted and hidden, limiting their view of data.

    The problem I'm having is that sometimes when deploying a report revision to the master, the practice_id parmeter becomes unhidden or hidden. The enterprise users sometimes lose the ability to select the practice, the practice users sometimes gain the ability to select the practice.

    I'd like to write a script using the rs utility to programmatically set the hidden property to true or false based on the report / linked report.  Am I going about this the right way? I cannot find scripting samples.  I could probably write some SQL against the reporting services database, but that seems like a hack and is risky.

    Thanks,
    Myles

    I think going through the SOAP API might be the only way and quite a pain. 
    Seems like you could be hitting a known bug...one of those that's been active for almost ten years now. Check this connect item about parameter defaults and hidden/visible properties. Read the comments as there a few different things people have hit with this:
    Report parameter defaults not updated during deployment

    Sue

  • So here's the rss script I came up with as a solution.  Using the rs.exe command line prompt: rs -i scriptfile.rss -s http://yourserver/reportserverinstance


    Public Sub Main()
     ' this is based on 2005 namespace

     ' declarations
     Dim forRendering As Boolean = False
     Dim historyID As String = Nothing
     Dim values As ParameterValue() = Nothing
     Dim credentials As DataSourceCredentials() = Nothing
     Dim parameters As ReportParameter() = Nothing
     Dim rp As ReportParameter
     Dim blChange As Boolean = False
     Dim dfv as String
     Dim practice_id as String
     Dim items As CatalogItem() = Nothing
     Dim itm AS CatalogItem = Nothing

     Try  

      ' Retrieve a list of all items from the report server database.
      ' practice home has subfolders with the practice id
      ' such as /Practice Home/0001/ with reports underneath
      ' reports are linked reports, to master in separate secure folder
      items = rs.ListChildren("/iA Home/Practice Home", True)

      For Each itm In items
       blChange = False
       If itm.Name = "Measure Trend" Then
        parameters = rs.GetReportParameters(itm.Path, historyID, forRendering, values, credentials)
        If Not (parameters Is Nothing) Then
         For Each rp In parameters
          If rp.name = "practice_security" Then
           dfv = "" ' default value, only one, not a multi-value parameter
           practice_id = "" ' will derive from folder path
           If Not (rp.DefaultValues Is Nothing) Then
            dfv = rp.DefaultValues(0)
           End If
           practice_id = itm.path.substring(23,4)
           If  rp.PromptUser = True OR practice_id<>dfv Then
           ' should be hidden and fixed to practice id
            Console.WriteLine("Changing " & itm.Path & " parameter " & rp.Name & " from > to")
            Console.WriteLine("  PromptUser: " & rp.PromptUser & " > False")
            Console.WriteLine("  Prompt: " & rp.Prompt & " > blank")
            Console.WriteLine("  DefaultValue: " & dfv & " > " & practice_id)
            rp.PromptUser = False
            rp.Prompt = ""
            rp.DefaultValues(0)=practice_id
            blChange = True
           End If
          End If
          If rp.Name = "measure_practice_list" AND (rp.PromptUser = True OR rp.Prompt<>"") Then
           Console.WriteLine("Changing " & itm.Path & " parameter " & rp.Name)
           Console.WriteLine("  PromptUser: " & rp.PromptUser & " > False")
           Console.WriteLine("  Prompt: " & rp.Prompt & " > blank")
           rp.PromptUser = False
           rp.Prompt = ""
           blChange = True
          End If
         Next rp
        End If
        If blChange Then
         rs.SetReportParameters(itm.Path,parameters)
        End If
       End If
      Next itm

     Catch e As SoapException
      Console.WriteLine( e.Detail.InnerXml.ToString() )
     End Try

    End Sub ' Main

  • Very nice...not as bad as I thought it would be but then again, I didn't write it! Thanks for posting that. The Web Service/SOAP API does expose everything so anything should be doable. And now that you've run through this one, any others for you in the future should be much easier. 

    Sue

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply