Search code examples
sql-serverreporting-servicesssrs-2008ssrs-2012ssrs-2008-r2

SSRS data driven subscription email to : parameter dependent on report parameter?


Hi I am using visual studio 2015 to make an SSRS 2014 report. The place I am stuck at is my email recipient is dependent on what company is selected from the SSRS report.

Not that it should matter but my report parameters are Company (really companyID),begdat,enddate.

select email from users where companyid= @companyid<< which would be my selection.

Most examples I see have a defined list of emails or just 1 person to email. I want to send a report per company only to the users of that company aka dynamic recipient list.


Solution

    1. Modify your query as: select email, companyid from users

    2. At the next step in select an option Get the value from the database for the TO field and set it to email.

    3. At the next step change your company option to Get the value from the database and set it to companyid.

    Then users from company CompanyA will receive only a CompanyA report, and CompanyB - only a CompanyB report.

    You could debug the subscription using temporary query with only your email:

    select email='your@email', companyid = 'CompanyAid' UNION ALL select email='your@email', companyid = 'CompanyBid'