Skip to main content

SSRS PHP Tips and Tricks Default parameters

Have you ever wanted to share a report between several different people or companies, but wanted the report to only display data for that specific person or company?  This can be tricky with a multi company or multi person database.  However there is an easy way to do this, and it's not coping and pasting the report for each company/user.

There are 2 steps to do this.

The first step is easy.  When creating the SRS report, create a person or company parameter, just a normal text field parameter.  This will be the parameter be used to set which specific person/company the report will be for.  It would probably be a good idea to use a different naming convention for this parameter, to specify that it as a default parameter, like default_user.  Then finish creating the report and onto the next step!

The second step is to change your code where you set/send the report parameters to the SSRSPHP library.  All you have to do is check if the parameter name is equal to one of the default parameters and hide the parameter from the user when setting the parameter.  Then when the report is being submitted, all you have to do is set the parameter before sending it to the SSRSPHP library to retrieve the report.

Now the user won't be able to change or even see the parameter.  This is pretty good, but if we want to add more default parameters this isn't a very elegant solution.  Instead we can put all the default parameters into an array and check if the default parameter exists in the array.  This way in order to add more parameters, all we have to do is change an array.

To the user it will seem like nothing has happened, but we have effectively limited the user to see the report data that we want them to see without having to create separate reports for each company or person.

By: Dustin Yee, Application Developer, , WebSan Solutions Inc., a Canadian Certified Microsoft Partner

Compare SaaS Against On Premise Software
Implementing BC PST and PEI HST in Dynamics GP