Can we write a function in SSRS globally - reporting-services

Im currently using SSRS-2008R2. I've an scenario where i have to maintain the External image as a logo for each reports we have. Not, only that, we have our custom date formats that what we should change according to the Date Type users define in an asp.net application.
There are lot of things we have to do on every report. Thats my problem.
Following is the one of them Im currently sharing as example :
Currently i maintain the following function for each reports i've:
Public Function GetLogoImage() As String
Dim ImageLogoURL As String
if Globals!ReportServerUrl is nothing then
ImageLogoURL = "http://localhost/ReportServer" + "?%2fImages%2fLogo"
else
ImageLogoURL = Globals!ReportServerUrl + "?%2fImages%2fLogo"
Return ImageLogoURL
End Function
I hope, i asked question clearly. Im newbie in SO.
Thank you in advance.

If you have a list of functions that you wish to apply to multiple reports and you're not willing to copy them to every single one of them, you can create an external library and then add it as a reference to every report.
This is quite simple to do and there's lot of documentation around the web.You can start here. You will, however, have to maintain this external library but if you have a lot of code, I personally think this is a much better solution.
If you want to have a predefined layout, you may want to consider having a master report and then include other reports as sub-report objects, but you'll lose some flexibility design wise.

Since the accepted answer is more of a comment and the link provided is broken, i'll provide my answer for people who might need a quick guide on how to use custom code in ssrs:
In Design view, right-click the design surface outside the border of the report and click Report Properties.
Click Code.
In Custom code, type the code. Errors in the code produce warnings when the report runs.
Once you press ok, to call the function that you saved you just need to right click on a cell, select "Expression" and paste in the following string: Code.GetLogoImage
More detailed source here.

Related

SSRS Create Excel Icon on Report

Does anyone know of a way to add an Excel icon somewhere more visible for the user to do an export without having to click on "Actions". Not sure if any of that is customizable?
Additionally, is there a way to create a drill-through report that renders in Excel. I was trying to figure out the RS:format stuff, but not sure how to use this.
I'm trying to make the report as user friendly as possible.
Thanks.
There certainly is, you can do an export using a URL as detailed in this MSDN article: https://msdn.microsoft.com/en-us/library/ms154040.aspx.
All you need to do is set that as the action of an image you place on the report, and you have an export icon. The general format is:
http://myrshost/ReportServer?/myreport&rs:Format=Excel
The main item to note is that myrshost/ReportServer is not going to be the same address as you use when browsing through reports. Instead, it's probably going to be SERVERNAME/ReportServer_INSTANCENAME, filling in the name of your server and database instance respectively.
Edit: A more concrete example of what this would look like:
http://sqlhost/ReportServer_Report2016?/Rentals/Balance%20Overview&rs:Format=Excel

Scan an area of a web page's source code for changes while reporting it?

this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}

Report Title as a ReadOnly parameter in SSRS

I've tried searching all over the internet for anything close to what I'm looking for and have been very unsuccessful. What I am wanting to do is to create a parameter in SSRS that shows the name of the report in the parameters section. But I want it to only be a label, instead of having a drop down box. I know if you take away the available values it makes it editable. If there is even a way to make a default value read only without having to have available values I think that would be okay as well. Any help would be greatly appreciated.
Parameters are not meant for this purpose. Even if you building the parameters with the RDlObjectModel the report parameter object doesn't even allow the parameter to be read only. I suggest to write your own custom interface to show headers and use a report viewer control.

Matlab gui for selecting a text file and the utilize it in further code

I have spent a long time studying about the gui. I have made the blank template containing all the buttons and input editable text box. but am facing problem with callback functions.
I have written a code which requires manually entering the text file containing data into the script file and then input a variable's value (in this case 'b') which is then utilized in the later part of the code. i wanted to make the program more user friendly so that one can select the text file from any directory by pushing a button and can change the value of b in a box provided. Also I have not included any functions in the main code...so its a basic data fitting code.
I tried studying about gui in matlab and other resources but am not able to understand it and use it. Therefore i cant put any of my work done uptill now. Please help me in solving the problem..
You may create a button in your GUI and include the following code in the associated callback function:
[aux_file,aux_path]=uigetfile();
if ~isempty('aux_file')
handles.data.file_name = fullfile(aux_path,aux_file);
handles.data.file_data = load(handles.data.file_name);
guidata(handles.figure_window, handles);
end
Now, you can use the data in other functions.

Using "OutputTo" to create a report that has VBA code

I am using OutputTo to create reports, however my reports contain VBA code for styling and formatting, and when I use the OutputTo function it ignores my report-vba code.
My code:
DoCmd.OutputTo acOutputReport, "Report Name", acFormatSNP, "File Path", False
Do you know any way to automatically create reports that will execute the report-vba code?
Thanks.
If you want the output to look exactly the same as the report viewed in Access, PDF is probably the best bet (thanks to iDevelop). However, depending on your version of Access, you may not be able to create a PDF with OutputTo, it only became available in the 2007 version. An alternative is to build your own html output, which can be quite pretty.
I ended up removing the VBA code that was used for styling and editing.
GD Aducci,
I was having same problem and solved the issue by removing the VBA in the report.
Whilst contemplating my succes I was wondering what might be the solution for the issue...
Mind you it's an idea, not a tried piece of code.
Here goes:
If you 'flag' the result of the formatting and styling VBA code in your report and make it into a boolean variable, you would be able to sample/retrieve the variable from your execution code. I.e. you would be able to retrieve the 'rendering-status' of the document.
You could then delay the actual execution of the 'OutputTo' routine by checking if all flags are 'true' if all come back as true, then formatting and styling should be finished and hence exporting to PDF would be optional, if they do not come back as 'true' then 'OutputTo' routine should be delayed even further.
It appears that 'OutputTo' just continues execution without actually confirming if document rendering has actually finished and hence ignores (and conflicts with) any VBA coding present in the document. So only option is to check if all code has executed before presenting the rendered document to the 'OutputTo' command ?
Perhaps code the 'OutputTo' as function and refer to it from the rendered document...?
As I said, I haven't coded it -yet- but it may be the solution ?
cheers !