Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am struggling to pass a variable in a URL. I would like a value in the url to select the value in a field.
Here is an example URL: http://qlikviewdev/QvAJAXZfc/opendoc.htm?document=public/report.qvw&host=QVS@svr&partnbr=1234
In my script I set two variables:
SET partnum=0;
SET partnbr=0;
I setup a simple macro that I hoped would get the partnbr from the url. Here is the macro VB script that runs:
sub test
set partnum = ActiveDocument.GetVariable("partnbr")
ActiveDocument.Fields("PART_NBR").Select partnum.GetContent.String
End Sub
I run this macro on a button press, unfortuanitally it does not work. Can anyone help explain what I am missing, or how I should be going about this.
Thanks!
I have also attempted to accomplish this through Jscript which has also failed. Example functions:
//this function grabs the params from the url
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
try{
var results = regex.exec( window.location.href );
}
catch(err)
{
return err;
}
if( results == null )
return "Got Nothing From Params";
else
return results[1];
}
Whenever I run this I get an error about the window object... can the window.location object not be used? Anyone have any success getting at url params from JScript?
Hello,
Although it's not the most elegant solution, and its useness will depend on whether you know the name of the field you want to extract from the URL, you can use something like the following in your script:
Set vURL = http://qlikviewdev/QvAJAXZfc/opendoc.htm?document=public/report.qvw&host=QVS@svr&partnbr=1234;
Set eXtract = TextBetween($1, $2, '');
Let vPartnbr = $(eXtract('$(vURL)', 'partnbr='));
Hope that helps.
BI Consultant
Well my current issue is getting to that url string. I am basically looking for a way to access it, and have not been able to yet. Once I have that string, parsing it shouldnt be too much of an issue. Anyone know how to get it?
I have restructured my discussion here: http://community.qlik.com/thread/30326
Hi,
Anybody who ended up at this thread pls refer to my comments @ http://community.qlik.com/message/133891#133891
Cheers.