SSRS passing multi-value parameters to open report in additional window - javascript

We've created a report with Report Builder, published to the report server. Report 1, the primary report has 6 parameters; 3 multi-value params and 3 single value params. Would like Report 2 to open from Report 1 but in a separate window and pass all 6 parameters. In Report 2, they are also built as parameters. Parameters:
Neighborhood (multi)
Start (single)
End(single)
Source (multi)
Data_type(multi)
Prov_type(single)
In Report 1 we've created a text box with an action to open a javascript command. Here's the current call in Report 1 that opens another window but gives the generic error "not valid"
javascript:void(window.open('http://ourcompany/Reportserver/Pages/Report.aspx?%2fReports+in+Development%2funknown+provider+detail&rs:Command=Render&NEIGHBORHOOD="+join(Parameters!NEIGHBORHOOD.Value, "&NEIGHBORHOOD=")&"&SOURCE="+join(Parameters!SOURCE.Value,"&SOURCE=")&"&DATA_TYPE="+join(Parameters!DATA_TYPE.Value,"&DATA_TYPE=")&"&START="+Fields!START.Value+"&END="+Fields!END.Value+"&PROV_TYPE="+Fields!PROV_TYPE.Value+"'))
I've replaced "Fields" with "Parameters" and it still doesn't work. If I created it passing static fields it works as seen below;
javascript:void(window.open('http://ourcompany/Reportserver/Pages/Report.aspx?%2fReports+in+Development%2funknown+provider+detail&rs:Command=Render&rc:Parameters=true&NEIGHBORHOOD=Mesa&START=11/01/2016'))
Any thoughts? Thanks!

Part of the problem is that you are passing in the multi-value parameters multiple times. For example, part of your expression would result in:
...&SOURCE=A&SOURCE=B&SOURCE=C...
You can only set one value per parameter in the URL.
So the solution to that would be to comma separate the values and pass them in as a single string. Then, in the subreport, you would need to parse them out again.
"&SOURCE=" & join(Parameters!SOURCE.Value,",")
You may run into additional issues such as URL length limitations, but this will fix the immediate problem.

Ok, so I've worked out the syntax and believe that is working. I took out a few extra ampersands I had in there. Here's the code working:
javascript:void(window.open('http://ourcompany/Reportserver/Pages/Report.aspx?%2fReports+in+Development%2funknown+provider+detail&rs:Command=Render&NEIGHBORHOOD="+join(Parameters!NEIGHBORHOOD.Value, ",")"&SOURCE="+join(Parameters!SOURCE.Value,",")"&DATA_TYPE="+join(Parameters!DATA_TYPE.Value,",")"&START="+Parameters!START.Value+"&END="+Parameters!END.Value+"&PROV_TYPE="+Parameters!PROV_TYPE.Value+"'))
However, I have an entirely different issue now. Looks like an SSRS bug. I get the error, "report parameter 'START' is not valid for its type. (rsReportParameterTypeMismatch)" In both reports they are date/time values. I've done all the tricks by changing the system datetime formats to no avail. Any thoughts on this one? Thanks

Related

Excel Javascript Add-in - Access to property denied

I am currently working on a Excel Javascript Add-In that is supposed to go through an extremely big amount of Data to take a value from one column, seperate it into certain strings and paste those strings into seperate columns.
My problem is with accessing the value of the cell.
I am using the standard procedure (see below) which is also used in the sample code given by Visual Studio (Community 2017).
When I print all the possible properties of the given cell into the console, some have a note next to them that says: "" which is German for ""
Therefore I can´t access these properties and not get any result for the "value" property.
The strange thing is that the same code already worked in another project and therefore another project.
The code is basically
var sheet = context.workbook.worksheets.getActiveSheet();
var range = sheet.getRange("C1:C1").load("values,text");
var value = range.values[0][0];
The property notes:
I received the following error code:
Error: PropertyNotLoaded: The property 'values' is not available. Before reading the property's value, call the load method on the containing object and call "context.sync()" on the associated request context.
I searched the internet a lot and tried to find an awnser but I couldn´t find anything. I hope you guys can help me.
Thank you very much!

Accessing Collection Variables in Postman

Feature
Postman added support for variables, authorization, pre-request and test scripts to collections.
(As of version 5.4.1 this exists at both the collection AND the folder level.)
Use case
Let's say I want to store a refresh token when the login endpoint is hit. My test script needs to create/update a COLLECTION variable, NOT a global or environment variable.
Once that refresh token is available to the collection, other tests and pre-request scripts, I would think there is a way to access them through an API similar to pm.environment or pm.globals. (pm.collection, for instance)
Question
I cannot find any documentation on how to access or modify those via pre-request scripts, or tests... Does anyone know how to do this? Maybe this hasn't been thought out completely, or not fully implemented, but I thought I would check with others for some help.
Temporary Solution
As a complete hack, I am storing the things I need as namespaced environment variables. It's not ideal (makes things kind of messy when working in other collections) but it works just fine.
Collection variables
You can access collection variables (and all variables) in the pre-request and test script sections using pm.variables.get("variableName").
However, you can only define and update collection variables by editing the collection details via modal.
Note: For your current solution using environment variables getting messy, remember you can always use pm.environment.set() to reset the value or pm.environment.unset() to clear it.
Postman v7.9.0 added support for new pm.collectionVariables, so you can update them on test scripts:
pm.collectionVariables.set("collection_variable", newValue);
https://github.com/postmanlabs/postman-app-support/issues/5053#issuecomment-542555156
Setting collection variables manually and then getting them
was always possible.
Setting collection variables in scripts and not just manually
became possible in version 7.9.0 which was released in October
2019.
As of writing this, there is still obsolete misinformation about it
out there - on the internet in general - but sadly also here
at Stack Overflow.
Although this question has already been correctly answered, I am adding this answer in an
attempt to clear up any remaining confusion.
A collection variable can be set in a script
To find out who is right and
who is wrong, I made a simple
little experiment.
Below I describe what I did.
You can replicate the exact same experiment yourself.
I have created a Postman collection named ManipCollVars.
(ManipulateCollectionVariables seemed a little too long.)
You can download and save it to your local drive from:
https://user.it.uu.se/%7Ehesc0353/postman/ManipCollVars.pm_coll.json.
Then - from your Postman desktop app (not the chrome extension) -
import ManipCollVars (Collections > Import > File >
Upload Files) as shown in the figure below.
(The dummy GET request is https://postman-echo.com/get.)
^ click to enlarge
The initial value of the collection variable CollectionVar
In the left pane, on the same line as ManipCollVars is displayed,
click on the ellipsis to the right (the three mini circles: •••), and
then Edit.
See the figure below.
Next click on the Variables tab.
Note that the CURRENT VALUE of CollectionVar is "Initial Value".
Run the dummy request and the Tests script
Click on the request ManipCollVars-Request, and then on its Tests
tab as shown in the figure below.
Focus on lines 7-11:
// Will now try to change `CollectionVar` to some new value:
pm.collectionVariables.set('CollectionVar', 'Some New Value');
// Then print the new value of `CollectionVar` to the console:
console.log(pm.collectionVariables.get('CollectionVar'));
// ^ Does CollectionVar contain "Initial Value" or "Some New Value"? ^
Click on the blue Send button, and then open the Console
in the bottom left corner as in the figure below.
Note how the value of the collection variable has changed from
"Initial Value" to "Some New Value". - Issue settled!
Double-checking the value of the collection variable
To double-check that the value has indeed changed, click once again on
the ellipsis (•••) next ManipCollVars > Edit > Variables.
Note that the CURRENT VALUE of CollectionVar is now
"Some New Value". - Confirmed!
^ click to enlarge
References
Correct answer to this question
Defining variables in scripts
Postman Quick Reference Guide: Collection variables
Using collection variables in scripts
Answer to "Using Collection Variables in Postman"
Postman: The Easy Way to Work with APIs

Tests fail on travis, which pass local

My tests which turn green local, are getting red on travis. It's about this code:
And I change the year to "nineteen-ninenty-seven" # features/step_definitions/application_steps.rb:9
And I attempt to save the changes # features/step_definitions/application_steps.rb:17
Then I should see a message indicating that the data is invalid # features/step_definitions/application_steps.rb:26
expected to find text "Value must be of type integer." in "Provider configurations root name artist year" (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/application_steps.rb:27:in `/^I should see a message indicating that the data is invalid$/'
features/editing_resources.feature:52:in `Then I should see a message indicating that the data is invalid'
This is in my support/capybara.rb
require 'capybara/cucumber'
require 'capybara/poltergeist'
Capybara.app = App.new
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
It's about this code:
When(/^I change the year to "(.*?)"$/) do |year|
find('input[name="root[year]"]').set year
end
When(/^I attempt to save the changes$/) do
find('input[type=submit]')
end
Then(/^I should see a message indicating that the data is invalid$/) do
expect(page).to have_content('Value must be of type integer.')
end
The problem:
When I run the tests local, they turn green. I debugged it there. I'm for sure that the code works well. The fields exist and get filled with the right data. When I use pry in my local tests on the point that I expect the message, I 'source' (or html), and I can find the text myself. On travis/ubuntu this doesn't work. I can confirm this doesn't work, cause I contacted Travis and they gave me a VM for a day where I duplicated the problem.
To solve it, I tried multiple things, I increased waiting time, tried selenium/webkit and selenium with chrome/firefox. They al work local, but I can't get them working properly on travis.
What I want to achieve is that the test validates if the user see's a messages which is getting created when a field isn't filled properly (text in integer field in this example).
The message is created by Json editor. https://github.com/jdorn/json-editor
And looks like this in code:
<small class="error">Value must be of type integer.</small>
A logic explanation in my opinion: in travis, the dom doesn't get the newest version which should load after an activity get's executed (like fill_in or set) and local this does work.
I hope somebody has an explanation and a solution.
Although I can't provide an answer for your exact problem, I can try to help you debug the issue with the information you provided.
Regarding Poltergeist:
Poltergeist allows you to take screenshots at specific points in your test
Depending on your tests, one thing that you may need is some fonts. If you're getting errors on a CI that don't occur during development then try taking some screenshots
I would try using page.save_screenshot before and after the points you identified and see what the differences are between local/travis.
EDIT: There is also a gem for capybara that takes screenshots whenever a test fails. Find more info here: Capybara-Screenshot

Javascript in SSRS not handling number sign correctly

I am using some JavaScript code in SSRS to open a link in a new window on a report. The report links point to file locations on a server. The code I am using within Reporting Services for the link is:
="javascript:void(window.open('"+ "file:" & Replace(Fields!FilePath.Value,"\","/") + "','_blank'))"
This code works just fine when the file name is something 'normal' such as:
\\myserver\images\Files\1969\1-000-002_SE 82ND AVE 1_1969.pdf
However, when there are special characters (at least # for sure), I get an error message. This is what happens. An example file name would be:
\\myserver\images\Files\1978\1-001-003_SE 82nd AVE #12 1_1978.pdf
In this case what gets returned as the URL is:
\\myserver\images\Files\1978\1-001-003_SE 82nd AVE
As can be seen, the URL is cut off at the first instance of the number sign. If I copy the shortcut for the offending link, this is what I get:
javascript:void(window.open('file://myserver/images/Files/1978/1-001-003_SE%2082nd%AVE%20#12%201_1978.pdf','_blank'))
It appears that the JavaScript is encoding the file path correctly but something is getting lost in translation between the JavaScript code and the URL.
I am unable to change the file names so I need to come up with a way to work with the special characters. I have tried using EncodeURI() but could not figure out how to format it correctly in SSRS to work with the existing JavaScript.
Any ideas would be welcomed.
URLs will recognize the HTML character numbers. So, outside of your JavaScript, use an SSRS replace function for each special character you expect to find, replacing each with its corresponding HTML number code. For instance, a pound sign is %23; and a space is %20.
Note, I have some pages that use pound signs to split out URL parameters, and this does NOT seem to work in those cases. However, it might work in your situation. To try this, change your function to the following:
="javascript:void(window.open('"+ "file:" & Replace(Replace(Fields!FilePath.Value,"\","/"),"#","%23") + "','_blank'))"
In case this does work for you, you can find more of these codes here.

Partial Javascript Statements Logged To Server

I have some code that generates URLs to be used in various places across a site (image src, link hrefs, etc). I am seeing lines in the access logs which show some of the javascript code that generates the URLs masquerading as a file request.
For example, "/this.getIconSrc()" is one that I'm seeing quite a bit. I can't figure out how or why this is occurring and I can't manage to reproduce it without actually entering "http://whateverthesiteis.com/this.getIconSrc()" into the location bar. In most cases, these functions are chained together to generate a URL but the whole function chain does not appear in the server logs, just part of it.
I've probably invested around 30 hours trying to figure out why this is happening but cannot. It doesn't appear to be a browser issue as I've tried in IE 6/7, FF 2/3, Opera, Safari 3, and the problem does not occur. Has anyone else experienced something similar and, if so, what was the solution?
There's three possibilities really:
A bug in your HTML - malformed HTML causing onclick to leak into href, for example
A bug in your Javascript - myIcon.src = 'this.getIconSrc()'; - note the quotes that shouldn't be there
A poorly-written spider is hitting your site (like #Diodeus said: ___)
Edit:
Check the User Agent and Referrer in your logs - they may offer a clue.
Are you generating JavaScript calls like this? This may explain it.
___
#RoBorg... I'm thinking the most likely scenario is #3 since this particular function is actually only called in one place...
function whatever(){
var src = this.getIconSrc();
return src.replace( /((?:https?:\/\/)?(?:[^\/]+\/)*)[^\/]+/, '$1newimage.png' );
}

Categories