AJAX Client Triggered Reloads (and a general API framework for Server)
I have been asked this question the most, and I also see this appear numerous times on the Community and other blogs. Stefan Walther has done an amazing amount of work to solve this problem. The solution requires IIS, Stefan's EDX wrapper written in C#, and Stefan's Javascript extension for QlikView. Although I have not tested it, the architecture tells me that it probably violates the same-origin policy and will require browser configuration change on each client.I ventured out to find a simpler alternative and in the process I discovered how we can use the QlikView Automation API, and thus Desktop style macros, with a Server deployment.
Perhaps the simplest way to trigger a reload from AJAX client is to create a button that does a Server side export, and write a script on the Server that waits for the export file to appear. When the file appears the script will use qv.exe to do the reload, delete the export file, and continue to wait for the export file to appear again. Different file names can be chosen to indicate full or partial reload etc. The only additional software required with this approach is a script, which could be a dozen lines of batch file or VBScript.
A little more sophisticated way of sending messages from AJAX clients to your scripts, because that it is essentially what we are trying to do, is using DynamicUpdate. DynamicUpdate can insert, update and delete data rows loaded in memory. The changes are instantly and simultaneously visible to all clients. DynamicUpdate commands can be conveniently programmed as button actions. Changes to in-memory data can be monitored and acted upon as follows.
- A button with Action DynamicUpdate Inserts, Updates or Deletes rows into a table, not related to business data, to signal what it needs to do
- The Insert, Update or Delete can be conceptualized as a message that the client is broadcasting to all other clients
- A Desktop client that has the document open in Server is able to see the message in terms of Insert, Update or Deletes on a certain table or tables that it is monitoring
- The Desktop client (same or another instance) has also opened the QVW file that is loaded by the Server to perform Reload and Save. This is required because the Reload and Save aspects of API are disabled when the Desktop client loads a document from Server
- The Automation API exposed by the Desktop client is now available to macros and/or external scripts to access memory data loaded by server, which allows to read "messages" sent by other clients, and to perform reloads
- The macros and scripts are written the same way as you would for a Desktop application, thus restoring the missing macro functionality in a Server deployment. Not only can you process messages sent by clients, you can also update data back to a database server etc. based on changes made my clients, which is the other frequently asked question