Is possible make macros that run server-side?
10/17/2011 5 comentarios
Well, the truth is that it seems a simple question but it is quite difficult to answer, even certified developers have assured me that macros are ALWAYS on the client side only.
Based on this definiciíón macros are very limited to automate some tasks client-side as long as security settings and / or the type of client permit, what is almost useless …..
Interestingly there are a couple of check boxes in the console QEMC on QVS, tab “Security” at least arouse curiosity about the meaning of their existence:
When one begins to search for information in the forums and the QlikView’s official blog there are a lots of questions and answers, many in tone in which macros can not run server side, others work only in some cases and as many unclear responses that only contribute to confusion.
The truth is that I have’nt still completely clear on the context and situations in which macros run Server side so I’ll just let my experience and the steps to reproduce It.
1 – First you must enable in QEMC checkboxes that allow macros to run on the server side, as seen in the previous screen.
2 – Then create a qvw file with a button and associate It with the click of a macro:
Sub Prueba_Macro 'Macro Test Const ForAppending = 8 Set objFSO = CreateObject ("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ ("C:\TestServerSide.txt" ForAppending, True) 'Create a file on disk c:\ in where you are running (client or server) objTextFile.WriteLine ("test text line 1") 'We add text to the file objTextFile.WriteLine ("test text line 2") objTextFile.Close 'We closed the and save the file Set objfile = objFSO.OpenTextFile ("C:\TestServerSide.txt", 1) 're-open the newly saved file for reading Do Until objFile.AtEndOfStream 'read the file contents strCharacters = objFile.Read (1) text = text + strCharacters Loop Set objTextFile = objFSO.OpenTextFile _ ("C:\TestServerSide2.txt" ForAppending, True) 'Create a second text file in c:\ objTextFile.WriteLine (text) 'We recorded what we read the in first file end sub
3 – Finally recorded our qvw and publish it on the server.
4 – Then access to the Access Point of your server and using client AJAX (it does not work with IE Plugin, at least with this configuration) access to the application you just created.
By pressing the button on the client does not observe anything, but if you go to C: \ drive on the server side you’ll see that the files were created there, which means that the macro was executed server-side (you must ensure that the login used to access the application must have read-write permission in the destination folder, in the example C:\).
One of the problem with this is that if within the macro put a “msgbox (” Successful recording “) (eg) to give feedback to the user, the macro will stop working because it is set will to run on the server and this is a unattended server-side run so that no one will click on “Ok ” pop-up’s button.
To give some kind of user feedbak we can add a second action of the type “External / Set variable” and assign a value “true” to a variable used to display a text item conditionally hidden where we display a message indicating the result of the action.
In conclusion: YES, macros server-side work, and certainly the developers did not put QlikTech’s settings configuration (run macros in server) just to “do marketing”.
If there is no clear documentation you must “test” what instructions do work and which are’nt, understanding that it’ll be unattended execution with little feedback, but it is an excellent functionality to extend the limitations and expand areas of use of QlikView .
I hope you found it usefull, and until next time !