Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamically change URL of a button

In QlikView 9, I need to write a macro which take an existing button within a document and change the URL which the button launches based on selections within the sheet. I know how to find the selections and build the URL, but what I cannot determine is what properties to set on the button.


set btn = ActiveDoc.GetSheetObject("BU23")
set prop = btn.GetProperties
--- In here, I need to set the properties for the URL to launch when the button is clicked
btn.SetProperties prop


I've checked through the forums and have not found an example of this, and the API reference refers to a type if IArrayOfActionItems but that type is not defined in the API qvw.

Thanks!

12 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

You are correct, that definition is missing in the API Guide.

A workaround I can suggest. Have your button call a sub where you can open IE with the manipulated URL. Something like this should work:


strLink= "http://www.yahoo.com"
Set objIExplorer = CreateObject("internetexplorer.application")
objIExplorer.visible = True
objIExplorer.navigate strLink
Set objIExplorer = Nothing


Not applicable
Author

I should add that I need this to work when used from the QlikView server. Launching an application won't work, as it runs on the server.

disqr_rm
Partner - Specialist III
Partner - Specialist III

You sure this doesn't work on the server?

Can you try putting just someple line in sub and test it out another option, which works in "web" environment usually. Just call:

window.open http://www.google.com

Sorry, don;t have access to a server right now.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Instead of messing with properties, define the button launch action as a variable and then manipulate the variable contents.

-Rob

Not applicable
Author


Rob Wunderlich wrote:
Instead of messing with properties, define the button launch action as a variable and then manipulate the variable contents.


That's actually the first thing I thought of, but it doesn't seem to work. It's possible I'm doing something wrong.

Can you provide an example of setting the target of a launch action as a variable? I've gotten the variable set via the macro, but I cannot get the button to then launch the location specified by the variable.

-Kevin

Not applicable
Author


Rakesh wrote:
You sure this doesn't work on the server?
Can you try putting just someple line in sub and test it out another option, which works in "web" environment usually. Just call:
window.open http://www.google.com
Sorry, don;t have access to a server right now. <div></div>


I believe window.open is for VB, not VB Script, but I will confirm that. I did this approach, which did not work on the server:

set app = ActiveDocument.Getapplication
app.Launch baseURL & "?" & params, ""


-Kevin

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP


troj wrote:Can you provide an example of setting the target of a launch action as a variable? I've gotten the variable set via the macro, but I cannot get the button


Kevin,

Attached is an example of deriving the launch URL from selections without using a macro. Two methods are shown, build the URL in an Expression and building in a Variable. Hope this is what you were looking for.

-Rob

Not applicable
Author

I've continued to play with this, in hopes of finding a solution. One thing of note is that I was originally trying this via the Ajax Client, which is something I'd still like to get working.

When I switch to the IE Plugin, I can use the following VB Script within a macro, and have it work. More than likely, this is because with IE, VB Script can run within the browser.

if (params = "") then
msgbox "No selections"
else
dim app
set app = ActiveDocument.Getapplication
app.Launch baseURL & "?" & params, ""
end if


I'd still like a method which works via Ajax, where the macro directly launches the page, or where I can change the launch URL for a button via a macro, or change a variable and have the button launch the contents of the variable.

-Kevin

Not applicable
Author


Rob Wunderlich wrote:
Attached is an example of deriving the launch URL from selections without using a macro. Two methods are shown, build the URL in an Expression and building in a Variable. Hope this is what you were looking for. <div></div>


Thanks, Rob -- that showed me where I went wrong! I was trying

=$(variable)


instead of

=variable


as the URL.

It's the little things....

I'll give that a shot with the Ajax client, and see if it works.

-Kevin