Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

akl
Honored Contributor

AJAX and URL parameters

Sometimes you want QlikView to open with a specific set of selections, apply a bookmark or perhaps even deep link to a specific sheet.

A typical use case could be to embed an entire app or a single object inside a CRM or ERP system and depending on the context, current customer for example, filter the QlikView app to only show records related to that specific context.

So how do I use this black magic?


One approach would be to use triggers with the obvious downside being that the trigger would always fire regardless of how you opened the app.

Another approach is to supply a set of parameters to the URL for that specific app.

Let’s take an example, the Sales Compass demo from the demo site. Below us the URL to access the app and the different components explained.

Actual URL

demo.qlik.com/QvAJAXZfc/opendoc.htm?document=qvdocs%2FSales%20Compass.qvw&host=demo11

Explained URL

<host name>/<virtual directory>/opendoc.htm?document=<url encoded full name for the application>&host=<name of QVS>

In addition to this URL you can also supply some extra parameters to control which actions will fire when the app is opened. For example the URL below will open the Sales Compass app with the value “Q2” selected in the listbox with id LB5699 (yes we create way to many objects )


demo.qlik.com/QvAJAXZfc/opendoc.htm?document=qvdocs%2FSales%20Compass.qvw&host=demo11&select=LB5699,Q2

Of course this is only a simple example, in the table below you will find all the available parameters you can append to your URL.

Feel free to mix and match these til your hearts content.

ActionParameterExample
Select a single value&select=<Listbox ID>,<Value>&select=LB01,Total
Select multiple values&select=<Listbox ID,(Value|Value2)&select=LB02,(2011|2012)
Open the app on a specific sheet&sheet=<Sheet ID>&sheet=SH01
Open the app with a bookmark applied&bookmark=<Bookmark ID>&bookmark=Server\BM01

Wait a minute, you mentioned single objects?

Ah, yes! When QlikView 11 was launched we also introduced the capability to display a single object from an app.

This allowed customers to integrate objects from different applications into a single view in a external system. It is also this screen that powers the small devices client.

Substitute opendoc.htm with singleobject.htm and specify the object id you want to display,

demo.qlik.com/QvAJAXZfc/singleobject.htm?document=qvdocs%2FSales%20Compass.qvw&host=demo11&object=CH378

And voila! You now have a fully interactive single QlikView object!

90 Comments
dvqlikview
Honored Contributor II

Nice one Alexander. Excellent blog post.

You delivered, as you promised few weeks back. Cheers!

337 Views
Employee
Employee

Great information. Didn't know about the single object.

0 Likes
337 Views
jason_michaelid
Honored Contributor II

Awesome info - thank you Alexander. I'll test it soon, but can you tell me if the "single object" can be a sheet...?

337 Views
akl
Honored Contributor

The singleobject.htm will only show a single object, not a entire sheet.

I usually just append the sheet=<Sheet ID> parameter to the "normal" app URL if I want to show a specific sheet. Then of course you could go wild and write a document extension that would hide the tabrow/menues if a specific parameter exists in the url if you also want to prohibit the users from navigating away from that sheet.

0 Likes
337 Views
jason_michaelid
Honored Contributor II

As explained in the main post...d'oh!  Thanks again.

0 Likes
337 Views
MCampestrini
Valued Contributor

Alexander, great post.

I'd never heard about it. I started to think what I can deliver to my users.

Thanks a lot.

0 Likes
337 Views
jason_michaelid
Honored Contributor II

Any way of specifying a field name? Maybe one you don't have a listbox for?

337 Views
MVP
MVP

Now thinking of use cases for single object in an iFrame...

Thanks for the heads up!

Steve

0 Likes
337 Views
Not applicable

Thank you for a great blog. Do you have an URL syntax for calling a report using Report ID?

0 Likes
337 Views

Hi Alexander Karlsson

I must say excellent post.

Can you share some light on passing UID and PWD in the url itself.

Regards

ASHFAQ

0 Likes
337 Views
shawn-qv
Contributor

Thanks Alex. This will definitely come in handy for all future development

0 Likes
337 Views
thanstad
New Contributor III

Very Nice, already tested it and informed the QV users in the company

/Tormod

0 Likes
337 Views
Not applicable

Stefan Walter has blogged about the subject and has built up a great set of resources for anyone to use, available here:

http://www.qlikblog.at/2343/qliktip-48-qlikview-mashup-examples-documentation/

some great examples too!

Erica

337 Views
sudeepkm
Valued Contributor III

the single object mode is wonderful. but i think I faced an issue as the chart caption was visible instead of the chart's window title. I can provide the exact error scenario once I find my qvw.

0 Likes
337 Views
Not applicable

Hi, just to say that Stefan Walter has done some great posts on the subject and source materials at his blog (google "Qlikview Mashups qliktip #48" - my last comment is waiting moderation for the link)

If you are searching multiple values, wrapping them in brakets sometimes doesn't work (the ( value1 | Value 2 |....) in some versions of qlikview

I separate my values with commas, and that works instead.

EG &select=LB42,value1,value2....

I use QV 10 SR6

Erica

337 Views
akl
Honored Contributor

Ye brackets was added for QV11 which also allows you to specify a entire search mask for selections.

337 Views
thanstad
New Contributor III

Iam looking for a solution to add a URL ie. with the latest periode. I would like to add YEAR(TODAY()) and MONTH(TODAY()) in the &select stmt, to make it most flexible for the enduser . I have tried but not succeded - is it possible ?

Tormod

0 Likes
337 Views
Not applicable

Yes it's much neater, I like it!

0 Likes
337 Views
akl
Honored Contributor

Hey Tormod,

No you can't leverage any native QV functions in the url. Normally this would be done on the embedding site, usually through javascript or some other language. A typical use case would to be extract the current user/customer/whatever and filter the data set depending on that context.

You might have all the orders in a QV app but want to show that information in your CRM-system, so instead of integrating the ERP and CRM-system on a data level you could instead have a table in QV that is filtered depending on the customer you view in the CRM-system.

337 Views
datanibbler
Esteemed Contributor

Hi,


that might be very usable in my scenario, but I'm not sure, maybe you can help:

- We have a pyramid-like structure with team-specific apps (lower level) and a mgmt_Dashboard (upper l.)

- When the managers open a team-specific app via document_chaining (in the browser) from the
    mgmt_Dashboard, then a specific sheet within that app should open, depending on which button in the
    mgmt_Dashboard they used (there might be several KPIs from the same app, so then every button should
    result in a different sheet opening)

<=> When the team members, who don't have access to the mgmt_Dashboard, open their team_app, it
         should always open on the homepage.


That functionality should actually be in Qlikview itself, but in our outdated version, it doesn't work. I'm wrangling with a macro that would open the sheets based on a selection in an inline_table that I can transfer with the doc_chaining, but that doesn't really work yet - not reliably anyway.

The question would be, how can I tell QlikView the precise URL it is supposed to open - could I perhaps use the action "open URL" instead of the action "open QlikView document"? Then it would only work in AJAX, not in the client_software, but if it works ...

Thanks a lot!

Best regards,

DataNibbler

P.S.: The Single_Object thing also seems great. I don't yet know any use for it and I don't know if it would be a good idea to open up that construction site, but that really sounds like we could do some pretty cool things with that.

P.P.S.: OK, it seems to be working - I am only wrangling a bit with the selections - by default, I need to make selections on several different fields (year and month or year and week). That does seem to work going from the overarching Dashboard in AJAX, but not going from the overarching Dashboard in the client_software ... can you explain to me why this is so and if I can fix it and how?

0 Likes
337 Views

I'm trying to use the singleobject.htm inside a web page viewer extension, but it renders as blank. I've confirmed that the URL works fine in a browser window. I've tried both the QV shipped web page extension and Stefan Walther's improved version.

Should this be possible in theory, and any idea where the problem may lie?

-Rob

0 Likes
337 Views
datanibbler
Esteemed Contributor

Hi,

very strange - sometimes this is working just fine, at other times the URL I pass seems to be interacting with something, either the sheet opens with some selections applied which are not part of the URL or, just the other way round, some selection or bookmark that is part of the URL is disregarded and the sheet just opens without any selections.

Best regards,

DataNibbler

0 Likes
337 Views
akl
Honored Contributor

Hey Rob,

Yeah it is possible. However with the extensions you are referencing they are simply inputting a iframe without setting any sandbox permissions. With the HTML5 spec we got more control over how a iframe can interact with the parent page and now modern browsers usually blocks script execution from within the iframe unless you explicitly set the sandbox properties.

For example, <iframe sandbox="allow-scripts allow-top-navigation" src="<your url>"> </iframe> should do the trick for you. Drop me an email at akl@qlik.com if you can't get it to work and I'll send you a modified version of the web page viewer extension.


EDIT: Rob: So I just tried it and you most likely also have to set the allow-same-origin sandbox attribute since we are loading qvajax.js and the css files of the QlikView server. If you open up the script.js file of the webpage viewer example change line 7 to:

el.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-top-navigation');

Also if you have third party cookies blocked in your browser the page will end up in a endless loop so please enable them as we use that to set the session cookie to track users.


Example of loading a chart through the webpage viewer extension or Yo dawg, I heard you like QlikView so I put QlikView in your QlikView.inception.png




337 Views
akl
Honored Contributor

Hey DataNibbler,

It sounds as you might have Session Recovery turned on in QVS? I.e the QlikView session will pick up where you last left off?

0 Likes
337 Views
thanstad
New Contributor III

Thanks, The original tread is very useful for our users. I have retweeted your post internal in our company as an alternativ to privat bookmarks. We have sometimes been into technical problems with AJAX and a few occations we needed to deleted the sharedfile and the users loosing their privat bookmarks. Now with this URL feature they can go on as before.

Tormod  

0 Likes
337 Views
akl
Honored Contributor

Hey Tormod,

Ah yes, the .shared file going corrupt is something we are aware of and have been investigating.

Once the file breaks I recommend that you try to repair it with the Power Tools Power Tools 1.2 for QlikView since it also contains any server objects that the users might have created which is a pain to re-create.

0 Likes
337 Views
Not applicable

Hey Thanks for this wonderful explanation!

I have a question here. How do I pass multiple listbox selections in the URL.

Say I want to select Q1 in Quarter and 2011 in Year together.

Please help me with this.

Thank you.

0 Likes
337 Views
thanstad
New Contributor III

Pramod Karanam I have been playing around with a few examples to our users and this one is a popular one

http://qv.xxxxxxxxxx.com/QvAJAXZfc/opendoc.htm?document=Group%2F610.CDGO%20-%20Demographic.qvw&host=...


0 Likes
337 Views

Thanks for the pointers Alexander. I tried modifying line 7 as suggested and got the error below in webview. However commenting out line 7 -- not setting any sandbox attribute -- works in both webview and the server. I'll continue testing.

-Rob

Capture.PNG.png

0 Likes
337 Views
Not applicable

Thank you Tormod!! Worked perfectly..

0 Likes
337 Views