Email SSRS Report as Excel Attachment On Demand - reporting-services

I have the following request from a client for feature to add to an SSRS report. I'm not sure it's possible to do what he's asking for. I haven't been able to find a way to do this after many Google searches, so I'm asking here - here's what he wants:
We would like a button added below “View Report” to send the report as an excel attachment to the CT Logistics inbox(copied here).
We would like a box added so the PM can enter their name and be CC’d to the sent report email.
The subject line of the email should be the study number “C####” plus “initiation Supplies”.
As far as I can determine, there's no way to add a "Send Email" button as he requests, I can only have the report send email every time it runs. I have no clue how to add a box for someone to enter their name to be CC'd on an email - I don't even know if that's possible. As for the subject line, the study number is part of the data set for the report, so I could put it into a data-driven subscription, but I don't see a way to add an Excel attachment of the report using that method.
Can anyone point me to the way to fulfill the user's requests, or else confirm that what he's asking for can't be done? I'm using VS 2005 and SQL Server 2008 R2 (this is what we have at work, I can't update the versions).
Thanks!

I think the closest you'll be able to do is the Data-Driven Description to e-mail an Excel report at a given time with the subject and filename (if needed) that includes the study number.
It won't be on demand nor will it be CC'd to any additional people.
Now that I think about it, you could query a table for the person to be CC'd. The table could be populated before run time.
New idea - add a CC parameter to your report with the default as null. When the report is run the first time, it won;t do anything since the parameter is null. When your report is re-run with the parameter, your dataset query populates a table with the CC address and timestamp before running the regular query. Your data-driven subscription runs every 5 minutes and sees the new record in the table and fires using the CC field.
IF ISNULL(#CCPARAMETER, '') <> ''
INSERT INTO YourCCTable
VALUES (#CCPARAMETER, GETDATE() )
... <Your query>

Related

How to get filtered view to work in an entity SSRS report

I am trying to build an SSRS report to be put in Dynamics CRM and run from a record in the Account entity. My initial query to pull the data is pretty simple, but the functionality of the SSRS report and filtered view aren't working as expected. I'm using the custom report data source from the CRM data source folder, so I know that's not the issue (see here).
Here's my query (which is very basic):
SELECT Name
,Address1_Line1
,Address1_Line2
,Address1_City
,Address1_StateOrProvince
,Address1_PostalCode
,kore_salespersonidName
,kore_coordinatoridName
,client_FulfillmentContactName
,OpenDeals
,OpenRevenue
,client_ActivationBalance
,client_SponsorLevel
,client_PreviousSeasonSpend
,client_CurrentSeasonSpend
,Description
,kore_industryidName
FROM FilteredAccount AS CRMAF_FilteredAccount
I've also tried to use a another one as a filter for the report using a where clause on the end of the first query, but that just returns a random list of results as well.
Here's the one I've used for the filter:
SELECT CRMAF_FilteredAccount.AccountId
,CRMAF_FilteredAccount.Name
FROM FilteredAccount as CRMAF_FilteredAccount
WHERE CRMAF_FilteredAccount.statecode = 0
This is a similar issue I have, but no resolution: Similar issue.
Any help is appreciated.
Looks like my issue was just a bug with CRM. If you originally upload the report and don't specify in the "Display In" that it needs to be in "Forms for related record types" then it doesn't look like it'll change even if you change that value and the report will always run for all records. I found this link where it suggested that I delete the report and reupload it, which solved the issue.

Report Builder 3.0 - permit user to add data in after report generated

Using Report Builder 3.0 against cubes which are produced overnight.
The report I'm designing is used to archive or transfer (physical) files for patients. Users run the report, print it & then attach it to files that are then sent to a central area which will archive/send the files on.
The report has a number of parameters which is designed to return a single patient. This all works fine.
One of the parameters (#prmReason) is a single choice on what is to happen to the files, eg, "Transfer" (transfer files to another office), "Archive - closed", "Archive - deceased", "Archive - excess" (office space is limited, so staff archive off 'older' files).
One of the fields returned is CloseReason. This field always has a value. If the field is empty in the database (as the client hasn't closed), then it will contain the value: "Unknown".
This field (amongst others) are either displayed or hidden, depending on #prmReason. Again - all working without a problem.
Now for the tricky bit.
If the #prmReason = "Archive - closed" or "Archive - deceased" then the report will display CloseReason.
The problem is if CloseReason = "Unknown" then I need to know the why the file is closed & display it on the report.
I want users to be able to choose a value from a list of closure reasons. I then want the choice to be displayed on the report. Obviously if there is a genuine reason then display this value.
So the effect I'm after is:
User selects parameters & runs report.
Report then checks to see why report is being run (eg #prmReason).
If #prmReason =("Archive - closed" OR "Archive - deceased") AND CloseReason = "Unknown"
Then somehow produce a list of CloseReasons that the user can select. This value is then displayed on the report.
I can even cope with it being a free text field. Just something so that the central area can update the database if necessary & save a phone call/email etc.
(Yes, I realise that I can have the list as a series of tickboxes that the user ticks after the report is printed, but this would be a useful ability in other reports).
EDIT: empty value of CloseReasons conflicted with stackoverflow formatting (sorry didn't review post properly). Value is actually less then symbol then the word Unknown and then greater than symbol. It doesn't really affect the problem
You could add an additional hidden parameter.
If this parameter is not set then display an small table on your report that has a list of CloseReasons.
You then set table cell's action property to open the a report, choose your existing report as the report to open but this time you can pass a value for the final parameter, which, as well as displaying the Close reason in your report, would also hide the close reason choices table described above.
UPDATE To make clear more clear.
The following is based on the Northwind sample database. I have a shared data source pointing to this database.
Create new report.
Add a data source pointing to the shared Northwind data source
Add a new data set pointing to the data source above with the following query
SELECT
EmployeeID,
FirstName, LastName, Address, City, Country, Title, Notes
FROM Employees
WHERE EmployeeID = #EmployeeID
Add some of the fields to the report to show some basic info.
We now have a simple report with a single parameter #EmployeeID
Next we want to show some actions for each employee. For flexibility, I'm making this list dynamic based on the employee's Country. This list could be static.
Create a new dataset dsActions with the following query
DECLARE #actions TABLE(ActionID int, ActionLabel varchar(20))
-- Get employees country
DECLARE #Country varchar(20) = (SELECT Country FROM Employees WHERE EmployeeID = #EmployeeID)
IF #Country = 'UK'
BEGIN
INSERT INTO #actions VALUES
(1,'Sack them'),
(2,'Buy them a pint'),
(3,'Promote')
END
ELSE
BEGIN
INSERT INTO #actions VALUES
(1,'Fire them'),
(2,'High 5 them'),
(3,'Ask them to run for office')
END
SELECT * FROM #actions
Add a table to the report to show these values.
At the moment my design looks like this. (All the expressions are simple fields from the first dataset to show the employee details, nothing special)
And when I run it I get this.
OK, now all the basics are done, we need to be able to call this report again, but with an action already chosen. We'll make the actions table clickable and pass the action's label to the report.
It's the same report, we will only ever have a single report.
First, add a new parameter called action to the report and make it hidden. Add a default value of 'noaction'.
Next we want to only show our actions table if the action parameter is set to 'noaction'. To do this, set the Hidden property of the action table (tablix) to the following
=Parameters!action.Value <> "noaction"
Next we want to add a text box that displays the result action parameter, but only when the action parameter is not noaction.
So add a text, set it's expression to =Parameters!action.Value and the hidden property to =Parameters!action.Value = "noaction"
Finally, we need to make our actions list call our report but with a specific action. To do this we need to modify the actions table.
First save the report, whatever name you choose is the name you will select as the target report as the report will call itself.
Right-click the cell that contains the ActionLabel and go to the text box properties.
Select the Action tab and then choose "Go to report". Choose the name of the report you are currently working on (this actual report as the report will call itself).
Set EmployeeID parameter to [#EmployeeID] and the action parameter to [ActionLabel]
I've used the label for simplicity but you could pass the ActionID as long as you account for this in the text box that displays the action.
Optionally you could format the text so it looks like a link,
The final design and action/parameter setup looks like this
When I first run the report I get the following...
As soon as I click one of the actions, I then get this...
Hopefully that's clear now.

How to create a custom SSRS user warning?

I have a report that can be VERY expansive - potentially returning hundreds of thousands of rows and taking 15+ minutes to render. The users have four inputs including two dates indicating the report range and two filters that default to (All). What I'd like to do is throw up a warning to the user if they try to run the report without selecting a single entity from either of the two filters, or if the user attempts to bring up more than one week's worth of data at a time.
Is there any kind of checking I can do at runtime in the report (short of coding it in the procedure) to warn the user that they are about to get more data than they can handle?
I would add a Hidden Parameter e.g. Accept_Run_Time_Warnings, with Static values e.g. Yes or No. The Default value would be set by an expression, based on the prior Parameters and your criteria e.g. entities selected, date ranges etc. If those conditions are met, Default = No, otherwise Default = Yes.
Then I would add a textbox to the top of the report body with the warning text to show the users, finishing with something like "Click here to continue with these parameters". This textbox would be hidden if Accept_Run_Time_Warnings = Yes. This textbox would have an Action to run the same report, passing the same paramters, but with the Accept_Run_Time_Warnings = Yes.
I would hide all other report body tables charts etc if Accept_Run_Time_Warnings = No.
I would edit the parameters for the main datasets to test Accept_Run_Time_Warnings - if No then they can pass non-existent values (to speed the dataset execution), e.g.
=Iif ( Parameters!Accept_Run_Time_Warnings.Value = "No" , "DUMMMY" , Parameters!Customer.Value)
Thanks for the ideas. We decided instead to break the report into two reports and removed the "All" option from either one of the two selection drop-downs on each report. The titles on the individual reports give a clue to the user about which one to use and clue them into the need for a selection.

SSRS Null Hidden Parameter in SharePoint Integrated Mode

I have a report (call it Report A) that was built using only the User!UserId to generate appropriate data for that person. This worked perfectly.
The feature was requested to be able to view other people's data through Report A, based upon security inside the underlying stored proc. I updated Report A to include a new parameter, EmployeeId, and created a new front screen report that has a "Go To Report" action, passing the EmployeeId. The Stored Proc takes both the UserId and EmployeeId, and returns the data for the requested employee, if the User has permission to see the data. This also works perfectly.
I set the EmployeeId parameter to be hidden, and a default value of null. This was to allow anyone who comes directly to Report A to be able to run for their data (no impersonation), as they are used to. Running from within BIDS, it works, but once I publish to SharePoint, I get:
"The report is missing a parameter value but prompting for it has been disabled."
I obviously don't want to prompt for the parameter, and value should be null in this case. Does SharePoint integrated mode not allow for hidden and null parameters?
In SSRS 2008 with Sharepoint, you need to prefix each parameter passed in the URL with "rp:". For example: URL.../RSViewerPage.aspx?rv:RelativeReportUrl=/TestReports/Orders.rdl&rs:Command=Render&rp:CLordID=1324381
From this MSDN page, it looks as though you may need to explicitly override the parameter value to set it to be null in the Manage Parameters dialog within the library/folder containing the report.

Parameter missing a value

I am new to reporting services and have a reporting services 2005 report that I am working on to use as a base report template for our organization. I am trying to place the date that the report was last modified on the report server into the page header of the report. However, I keep getting a 'ParamX' parameter is missing a value error when I try to This is what I have done:
Set up a Parameter ReportName with a default value of Globals!ReportName. It is also hidden and internal.
Set up a Dataset ReportHeader that calls a stored procedure that returns the date the report was last updated or another date, if the report is not on the report server. It has a parameter #ReportName assigned to the Parameter!ReportName.Value. The Dataset returns values when run on the dataset tab in the BI tool.
Set up a Parameter ReportVersion that has a default value Query From based on the dataset ReportHeader and picking the ModDate column. It is the last parameter in the report parameters list.
I assign a textbox to the parameter.
When I preview, I get "The 'ReportVersion' parameter is missing a value whether I place it in the report body or page header (which is where I want it). I have deleted and added the parameter again, toyed with the hidden and internal settings on it.
What does this error really mean, what I am missing, and can I even do this with parameters?
Thanks In Advance
Jim
If I understand what you're doing, it sounds like you want to be using a field where you're implementing a parameter...
You are returning the ModDate from the data source, correct? If you're doing this, you can simply throw a text box in there, and use something like this: =Fields!modDate.Value to display it.
Parameters are values that go in to the query, fields are what it returns.
Hope this helps...
EDIT:: OK so are you trying to retrieve the mod-date column value from the reportserver db? If that's what we're talking about, you'll need to add a few things to the report. Add a datasource to report db, a dataset containing the date (query below), a list object in the report linked to the dataset, and a textbox in said list object to display the field. If you hit the report server with a query like this:
SELECT MAX(ModifiedDate) AS ModDate FROM catalog WHERE name='myReportName'
That will return your modifieddate from the ReportSErvices Database as a field that you can use.