Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone.
We have a QlikView document where user can click on a button that will trigger VBScript. When opening this document locally everything works. Also when using QlikView installed in server to view this document then functionality also works. Problem is when server has published this document and we try to open it either from AccessPoint or as "open in server" from end user computer. I have attached the error message we get from end user computer( macro parse failed. Functionality was lost). To be clear then we have changed file paths when moving document from PC to server.
Here's the code that is behind VBScript:
sub ennustaja
dim horisontti
horisontti = ActiveDocument.Variables("horisontti").GetContent().String
dim objShell
Set objShell = CreateObject("Wscript.Shell")
dim ohjelma
ohjelma = "C:\PROGRA~1\R\R-3.1.3\bin\Rscript.exe"
dim scripti
scripti = " C:\PROGRA~1\R\R-3.1.3\bin\r_qlik_w_demo.R"
dim cmd
cmd = ohjelma & " " & scripti & " " & horisontti
objShell.Run cmd, 0, True
Set objShell = Nothing
ActiveDocument.ReloadEx 0, 1
end sub
The idea is that user has selected some numeric variable from 1-10 and then this variable is passed to data mining program R. That will run some analysis and creates new output table that is then used in QlikView by reloading document.
We have enabled module security for this document.
QlikView Server version is 11.20.12577.0.
Desktop Solution version is 11.20.127420.0.
Any help is appreciated and let me know if I can provide additional information.
Rain
If you use WebView when opening in server, not plugin, your macro code will run on QlikView server.
When you run your macro in Developer, it is executed on the client.
This probably will never work - as there are clear limitations on what Macros can do on server and this goes beyond what you can do.
So you will have to do something else to achieve this.
1) A button could start a more "modest" VBscript that will run on the server. Like creating a file on the server.
2) The folder where the file on the server will be created can be set up to be supervised by something called
Windows FileSystemWatcher: Google this:
3) This could trigger a regular VBscript on the server that will do all you wanted to do in the VBScript of your QlikView document
Mind you ... you will have to replace the ReLoadEx with for instance qv.exe /R xyz.qvw ...
Hi Petter.
Does your explanation of limitations also apply to this kind of test:
Script behind button:
sub test_cmd
dim objShell
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "C:\PROGRA~1\R\Documents\test.bat", 0, True
Set objShell = Nothing
end sub
And bat file simply does an output to txt file:
C:\Windows\System32\ipconfig.exe > C:\PROGRA~1\R\Documents\mynetworksettings.txt
Because this also works fine normally but not when triggered in QlikView document that has been opened in server.
Thank you.
Rain
If you use WebView when opening in server, not plugin, your macro code will run on QlikView server.
When you run your macro in Developer, it is executed on the client.
I am under the impression that when document is opened in server the option "turn on/off webview" is grayed out.
Yes I am almost 100% sure that using CreateObject() on the server is prohibited since it would open a wormhole of security problems ... I can make a quick check later this evening to verify it ... maybe you can change the security settings - maybe not.
I'll get back to you later.
I confirmed that I was wrong - it is quite possible to do the CreateObject() in a VBScript that runs as a Macro on the server. You will have to set the right security settings both for you application in your QVW but also enable:
Allow unsafe macro execution on server
Allow macro execution on server
This might not be a very wise thing to do - due to security reasons - but it is possible anyways.
See below:
But the ReloadEx I am very sure is mentioned to not work on a Server Macro ...
As I understand there are several ways to use QlikView document that is stored on a server and only one works in our case:
But Petter is correct- reloadEx doesn't work in any cases. So we probably have to set up reload from QlikView Management Console, create a scheduled task in server or write some custom code? Is that correct or does anybody know of easy way of accomplishing this? Something user friendly and that does reload immediately.
Thanks.
You can reload from the commandline/batchfile in at least three ways.
- Running QV.exe /R <yourapp>.qvw
- Running Qvb.exe
- qmsedx.exe to trigger QMC reload.
Finally you could also have tiny QVW which only purpose is to poll the filesystem for an inidicator file and if it exists will fail and then you can have a dependency that will execute your reload on this small qvw's failure.