Open SSRS URL in New Window - javascript

I have a report that passes an id that is used to access salesforce.com. I want to open SFDC as a new page from the URL hyperlink. However, nothing I do seems to be working!
="javascript:void(window.open('https://na5.salesforce.com/& Fields!id.Value,'_blank'))"
Fields!id!Value is the SFDC id that is being passed. I'm trying this in the expression to no avail!
I know it is something VERY simple but I'm just not finding it. Thanks in advance for the assistance!
UPDATE!!!
Figured it out!!! For the record, the syntax is:
="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "'))"

For the record, the problem with your original syntax was that you were trying to go from referencing an SSRS field to entering a string without separating the two properly. If you wanted your previous syntax to work (without removing the target window's name (i.e., '_blank'), you would do it like this:
="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "','_blank'))"
I struggled with this for a long time, but you can make these pretty complex as long as you're careful to put everything together correctly. You can also add multiple javascript commands (but no functions) in the same action expression. Below is one of my most complicated SSRS Go-to-URL Action commands:
="Javascript:"
& IIF(left(Fields!Name.Value,11)="RESTRICTED-",
"alert('Restricted!'); ","") & IIF(Fields!Name_Alert.Value = 1, "alert('Alternate Alert!'); ","")
& "void(window.open('"
& Globals!ReportServerUrl
& "/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render"
& "&rc:Parameters=true"
& "&Emp_Number="
& Parameters!Param1.Value
& “&ID=" & Fields!ID.Value & "'));"
The key is to make sure that any and all necessary single quotes required by javascript show up inside a string (i.e., "'").

Nonono, don't use ="javascript:void(window.open(.
First, it breaks PDF & Excel reports,
and second, it doesn't work in IE11 and possible also < 11.
Tested it, worked only in Chrome for me.
And third, it's a mess to put it together.
There's a far easier & better solution:
Add &rc:LinkTarget=_blank to your report access URL, like:
https://your-domain.com/ReportServer/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render&rc:LinkTarget=_blank
and it will open in a new window tab.
Edit:
If you want to make your own display page:
This is how you get all reports:
USE [ReportServer$MSSQL_2008_R2]
SELECT
[ItemID]
,[Path]
,[Name]
,[ParentID]
FROM [Catalog]
WHERE Type = 2
And this is how you can display all folders/reports at level x
;WITH CTE AS
(
SELECT
[ItemID]
,[Path]
,[Name]
,[ParentID]
,0 AS lvl
,CAST([Name] AS nvarchar(MAX)) AS RecursivePath
FROM [Catalog]
WHERE [ParentID] IS NULL
UNION ALL
SELECT
[Catalog].[ItemID]
,[Catalog].[Path]
,[Catalog].[Name]
,[Catalog].[ParentID]
,cte.lvl +1 AS lvl
,CAST(cte.RecursivePath + '/' + [Catalog].[Name] AS nvarchar(MAX)) AS RecursivePath
FROM CTE
INNER JOIN [Catalog]
ON [Catalog].ParentID = CTE.ItemID
)
SELECT * FROM CTE
WHERE lvl = 1
ORDER BY lvl, Path
If you only want the folders:
WHERE Type = 1
If you only want the data-sources:
WHERE Type = 5

If you are wanting to link to an external URL and want the links to work both within the report viewer and if you export to Excel for example, I use the following expression.
=IIF(
Globals!RenderFormat.Name = "RPL",
"javascript:void(window.open('http://www.domain.com/page/" & Fields!Page_ID.Value & "','_blank'))",
"http://www.domain.com/page/" & Fields!Page_ID.Value
)
It will use the JavaScript if viewing from within the report in the browser and standard linking otherwise.

Here is what I had used; it will open the ChildReport in a new tab, with a parameter voucher_id and its value passed from a dataset.
="javascript:void window.open(" &"'"& Globals!ReportServerUrl &"/Pages/ReportViewer.aspx?"&Globals!ReportFolder &"/JournalVoucher&voucher_id="&Fields!account_voucher_id.Value &" ','_blank')"

Related

php remove single variable value pair from querystring

I have a page that lists out items according to numerous parameters ie variables with values.
listitems.php?color=green&size=small&cat=pants&pagenum=1 etc.
To enable editing of the list, I have a parameter edit=1 which is appended to the above querystring to give:
listitems.php?color=green&size=small&cat=pants&pagenum=1&edit=1
So far so good.
When the user is done editing, I have a link that exits edit mode. I want this link to specify the whole querystring--whatever it may be as this is subject to user choices--except remove the edit=1.
When I had only a few variables, I just listed them out manually in the link but now that there are more, I would like to be able programmatically to just remove the edit=1.
Should I do some sort of a search for edit=1 and then just replace it with nothing?
$qs = str_replace("&edit=1, "", $_SERVER['QUERY_STRING']);
<a href='{$_SERVER['PHP_SELF']}?{$qs}'>return</a>;
Or what would be the cleanest most error-free way to do this.
Note: I have a similar situation when going from page to page where I'd like to take out the pagenum and replace it with a different one. There, since the pagenum varies, I cannot just search for pagenum=1 but would have to search for pagenum =$pagenum if that makes any difference.
You can use parse_str() to parse the query string, remove the unwanted parts and build the new one via http_build_query() like this
parse_str($_SERVER['QUERY_STRING'], $params);
unset($params['edit']);
$new_query_string = http_build_query($params);

Javascript indexOf not finding text in a variable

I am sure there is something simple that I am missing but I am stumped here.
The issue is that I am looping through an array of strings and using the string value to search for a part of that string using indexOf. The first time around the loop the index of is finding what I am looking for but the second time it is not.
Here is a fiddle - http://jsfiddle.net/jeremywrags/uSwjG/1/
the line that seems to be not working is this
var aliasIndex = fromclause.indexOf(" " + tableAlias + " " );
I am trying to build a SQL parser for a cloud app and the use case here is that when a table is aliased I need to get the original table name so that I can look up the table columns. The first time around the loop index of returns the index and then the table name. The second time around the index of is -1 and the table name is not retrieved.
If I need to provide more context please let me know.
thanks
It's not matching because on the second pass, tableAlias is the string " b" (note the space). So then you search for " b " (note two leading spaces), which isn't there.
Rather than using alert, use the debugger built into your browser. You can set breakpoints in the code, step through line by line, inspect variables, etc., etc. Doing that with this would have shown you, when looking at the variable tableAlias, that it had a leading space, hopefully helping you find the solution.
Here's what that looks like in Chrome's debugger, for instance:
(If you look at the jsFiddle source above the actual debugger's version, you'll see a debugger; statement in the code — normally you don't need that statement, you can just open your page, use the "Sources" tab to find your JavaScript file, navigate to the line, and click the margin to the left of it to set a breakpoint. But sometimes [for instance, when using jsFiddle], the debugger; statement is handy. What it does is, if the debugger is open, halts execution of the code at that point like a breakpoint does.)

Wordpress Editor converts ampersand to &

when I am setting the src of an iframe dynamically with the following javascript in Wordpress:
jQuery(document).ready(function(){
jQuery('iframe').attr('src', 'http://someurl.com/?originid=PORTAL&tijdsblokstart=1700&datum=2014-05-19');
});
The last 2 parameters are not picked up. I know it has someting to do with the encoding of the ampersand, but I tried everything...I'm lost now.
- &
- &
- &
- creating the whole iframe in jQuery
The src has to be set dynamically.
Thanks!
I fixed my issue by creating a function in an external js-file that generates the url for me. So avoid using the ampersand in the Wordpress editor. I would love to hear if someone comes up with a better solution.
http://codex.wordpress.org/Using_Javascript
Here's a workaround that worked for me:
char = '&';
char = char.replace('amp;', '');
console.log(char);
If your problem occurs in post content, there is no universal solution.
Indeed, the & is replaced by & by the wptexturize function from wp-includes\formatting.php:
// Replace each & with & unless it already looks like an entity.
$curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $curl );
It's hooked to the the_content filter in file wp-includes\default-filters.php :
add_filter( 'the_excerpt', 'wptexturize' );
The problem is that you can remove this filter but you will loose a lot of formating done by this huge wptexturize function.
One solution for op would be to find a way to remove the ampersand from the code. To do this, you can use jQuery.param to generate the querystring part of the url:
jQuery(document).ready(function(){
jQuery('iframe').attr('src', 'http://someurl.com/?' + jQuery.param({originid: 'PORTAL', tijdsblokstart: 1700, datum: '2014-05-19'}));
});
A really dirty solution would be:
to register a filter to execute before the wptexturize one using priority 9 (by default, priority is 10) so it change your ampersand to something really unique that the wptexturize function will not alter
to register a filter to execute after the wptexturize one using priority 11 that changes back your ampersand subtitute to a real ampersand

Remove prefix with unknown characters in JavaScript

I have a web page that the title is changed from 'Pagename' to '(1) Pagename' when there is an update on the page. That number increments to 50 each time there is a new update and then is maxed out showing '(50+) Timeline'.
When logging page views, Google Analytics shows the '(n) Pagename', which I don't want. So I found out how to manually change to logged page title, _gaq.push(["_set", "title", 'new title']);.
So my question is, how do I most efficiently remove the (1-50)/(50+) prefix and just get 'Pagename'? Is regex best for this?
This is what I'm using based on the answer from Ross:
var window_title = window.title.replace(/^\(\d+\+?\)\s/, '');
_gaq.push(["_set", "title", window_title]);
Yes, RegEx can do that.
window.title.replace(/^\(\d+\+?\)\s/, '');
Of course it depends on what software your site is using as perhaps it would be possible to just output the page title without that prefix in the relevant part of the template. So echoing that directly into the Google Analytics tag. But I think the above javascript is probably the easier solution to implement.

Dashboard widget: getting version number from Info.plist

I'm writing a Dashboard widget in Dashcode, and on the back side, I've got a string for credits. I want to include the widget's version number in that string, but if possible, I want to programmatically grab it from the CFBundleVersion or CFBundleShortVersionString key in Info.plist to avoid having to change the number in multiple places if and when I update the widget.
Searches on Apple's developer documentation, Google and various forums have proven fruitless so far. What I'd like to know is whether there's a built-in way to do this that Apple included but forgot to mention (like var version = widget.version(); or something), or whether my script will have to pull in and parse the entire plist before plucking out the one value I actually want.
Thanks for any help you can provide!
I seem to have found the answer: use Dashcode's "data source" facility to read in Info.plist as an XML data source. From there, this blog post showed me how to traverse the plist's structure and get the correct string (in this case, the fifth <string> element in the file, corresponding to CFBundleShortVersionString.
The function I ended up with:
function getWidgetVersion() {
var dataSource = dashcode.getDataSource("infoPlist");
var version = dataSource.selection().valueForKey("dict").valueForKey("string")[4]; // This line and the previous could probably be combined for the sake of brevity
if (typeof(version) == 'string') {
document.getElementById("creditsLabel").innerHTML += version; //I'll change this to just pass the number on
}
}
Since the text of the creditsLabel div has already been started off with a localized string, I get a nice little label saying "Version 1.0".

Categories

Resources