‘Magical’ QR Code Integration Into Qlikview

A recent post by Elif Tutuk on the Qliktech blog about using Recognition Technologies to get info into a Qlikview application got me to thinking: what else you could do with Qlikview and QR (Quick Response) Codes…and I think I’ve come up with something that whilst a little impractical is about as ‘Fancy-Dan’ as it gets!

Firstly Elif’s Original Blog: http://community.qlikview.com/blogs/theqlikviewblog/2012/01/19/making-everything-qlikable-with-recognition-technologies – it’s a interesting concept, I’ll be posting a similar thing in a later post that acheives the same but without the use of Extensions.

So what have I come up with? Allow me to set the scene; a Doctor is working away with a health infomatics dashboard in the QV Client, they spot some interesting data about a patient on the ward, they need to see the patient face to face to confirm…and need the data with them, they simply select a special tab within the dashboard and scan it with their iPad2 and ‘Shazaaam!’: the dashboard opens on the iPad on the same tab they were looking at with the all same selections applied…as Sir Johnny Ive would say; ‘Magical’.

I need to point out at this stage that this is a concept only; whilst I’ve proved it works I’m not advocating it as a production ready solution, it’s simply to show what’s potentially possible and to keep grey matter tested.

What do we need to achieve this setup?: A QV Server install (Tested with Enterprise v10 SR3), a QV Client install (Again v10 SR3), an iPad2, a QR Reading iPad App (I use QuickMark) and a dashboard with a built in QR Code generator on a ‘Transfer to iPad’ tab: I’ll give you a link to download that below.

First I’ll outline what happens to drive the process before getting into the detail, I’ve tried to get it as seamless as possible but I only thought of this this morning before a full day onsite so forgive me if I’ve missed something! This process can be easily integrated with any dashboard, it’s not complicated but takes a little getting your head round so please stick with me. There are 2 key ingredients here; a dynamicaly generated QR Code and a dynamicaly amended user specific bookmark; here’s what happens; when the user selects the special ‘Transfer to iPad’ tab a series of Actions are triggered to set the current selections and layout state to an existing bookmark, this bookmark is then appended to the end of the URL for the dashbaord which is used to generate the QR Code, the iPad2 then scans this code causing the URL to open in Safari passing the Bookmark parameter to the dashbaord. It’s a little trickier than that but that’s the basic principal.

Read on for the details…

1. QR Code Generation

You can download the basic QR Code Generator here: https://docs.google.com/open?id=0BxloTMUod74tNjkxZTZiOWYtNjE5OS00MjUwLTg3NzQtZWVlNGJiM2IzYWMy

 

I came across this a few years ago and have adapted it slightly to allow full size QR encoding via GoogleCharts – they don’t just do maps you know, this allows us to link a QR Code image to a variable which will be the URL and Bookmark ID we wish to apply; we’ll generate that next, the chart gets placed in the new ‘Transfer to iPad’ tab.

2. The URL

This stage is quite simple: the URL will pretty much be static apart from the final Bookmark parameter, the variable driving the QR will look something like: =’http://MyServer/QvAJAXZfc/AccessPoint.aspx?open=&id=QVS@MyServer%7CMyFolder/MyApp.qvw&bookmark=Document\’&v_BM_ID  On to the dynamic Bookmark…

3. The Bookmark

Why do we need a dynamic Bookmark; why not simply Save the dashboard and then just open it on the iPad via the QR? – Other users. If we just saved the dashboard with our selections any other user opening the dashboard would be presented with where you left off; not acceptable in the real-world, instead we have a Bookmark for each user of the dashboard (or that uses this process at least) that can be updated without effecting other users.

This could be done using Section Access for larger implimentations but I’ll outline the lo-fi method here. We’re going to use osuser() to lookup the relevant Bookmark to be used in the Actions, to do this I’ve used a simple 2 column .xls; column1 being a list of the osuser() values of the dashboards user base (‘User’ – to match to) and the second being the relevant Bookmark ID (Bookmark); this is then loaded into application via the load script as normal. We can now create a variable (v_BM_ID) driven by the following expression:

=fieldvalue(‘Bookmark’,(fieldindex(‘User’,right(osuser(),len(osuser())-index(osuser(),’\’)))))

I’ve trimmed the osuser() value down to make it more user friendly but this isn’t essential. The expression finds the row of the record in the User field that matches the current osuser() value and then returns the value from the User field on the same row eg: I’m logged in as ‘Matt123’, this corresponds to ‘BM01’ so this is returned as the variable result which is added to the end of our QR Code URL variable (see above).

Just as we have a record per user we also need a corresponding Bookmark creating for each user; in my case it’s BM01, all should be set to maintain the layout state. This is of course a fiddle as you could well have a large number of users and therefore require a large number of Bookmarks – I did say it wasn’t production ready.

4. The Actions

The final part. To get the process to hang together seamlessly for the user we need to set up the following Actions; ALL tabs apart from the ‘Transfer to iPad’ tab should have the following Action added that’s triggered ‘On Departed’: a ‘Replace Bookmark’ Action, in the Bookmark ID box simply refer to v_BM_ID (this ensures the Bookmark linked to the current user is updated). All this happens in the background and doesn’t appear to impact the user experience when moving from tab to tab; the bookmark is replaced with no delay at all. Finally the following 2 Actions need to be added to the ‘Transfer to iPad’ tab triggered ‘On Activate’: First; a External > ‘Run Macro’, for the Macro Name enter ‘Save_Macro’ and in the Macro Editor (Ctrl+M) enter the simple Sub:

Sub Save_Macro
ActiveDocument.Save
End Sub

The second Action should be a Selections > ‘Unlock and Clear All’ (to set up for other users) – obviously the Save may well overwrite someone elses changes so it’s a potential flaw.

And there we are; try doing that with Tableau! (please do, I’d love to know if this sort of thing is possible)

Now, the more attentive of you; or just those who’ve bothered to read the full post will have noticed that we don’t actually need the QR Code at all; if I’m the user the URL and Bookmark will always be the same for me; I could simply create a Homescreen Shortcut to the URL on my iPad and launch it at the right time…but that wouldn’t be ‘Magical’, it is of course the constantly updating Bookmark linked to the osuser() that is the secret sauce.

It’s certainly not going to change the world but it could be useful as a pre-sales gimmic at least and shows Recognition Technologies working the other way.

All the best,

Matt 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: