问题
I show a list of items with a field Assigned to, which are email addresses. Right now I have set up a subscription with distinct list of assigned to email addresses and sent the entire items list to all the users. I want to sent only the items assigned to a particular user to that user; Instead of having to sent all the items to all the users. Can this be done in SSRS? I would have to dynamically set the To address, and filter out the result dataset.
回答1:
Sounds like you need to set up a data driven subscription which is available with the enterprise edition of SSRS 2012.
Create the report with a User parameter that will create your list of items attached to an email addresses.
When you then create the data driven subscription you get the opportunity to create another SQL statement that can be used for addressees and to get values to pass as parameters to your report.
If your proc is created something like (yours will probably be a little more complex...)
CREATE PROC GetAssigned
@EmailAddress nvarchar(255)
As
IF @EmailAddress is Not null
SELECT EmailAddress,Item1,Item2
FROM MyTable
WHERE EmailAddress = @EmailAddress
ELSE
SELECT DISTINCT EmailAddress FROM myTable
You can run this proc in both the report and as the data driven subscription to get the list of email addresses to send and as the parameter to the report. (Although you could just add the SELECT DISTINCT
query to the box below rather than having it in the proc?)
To set up the Subscription (Enterprise version, right?)
Although, you could just enter the script in the box above.
SELECT DISTINCT EmailAddress from MyTable
- Then on the next screen when Entering recipients use the value returned by the proc
来源:https://stackoverflow.com/questions/30318484/dynamically-set-the-to-address-in-ssrs-reports-subscription