Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jonastemin
Contributor II
Contributor II

Executing Jscript function during load statement

Hi,

I'm trying to execute a Jscript function during a load script but it looks like the command is not executed at all.

I have the following Jscript function:

support.jpg

The functions works correctly when executing using "Run Macro" button.

I looked at previous forum posts and this command should work;

support2.png

How do a call a Jscript function from a load script?

Are there security settings that prevents this from working?

Thanks,

Jonas

15 Replies
jonastemin
Contributor II
Contributor II
Author

The current code looks like this;

Jscript

qlik3.png

Load script

qlik4.png

The script should connect to a web server that send a POST request to Google Sheets API to update the format of a specific sheet.

marcus_sommer

A qmc-tasks doesn't execute "classical" macros - by macro-functions during the load-script I'm not sure but I could imagine that this is also disabled.

In this case you could try to outsource your macro into an external batch which could be triggerred within the load with an EXECUTE statement. Here an example what is meant: Re: Run Excel macro via QMC.

The input/output from your routine mustn't be necessary a parameter for the batch-call you could also use QV store/load for it, for example:

[$(sPath)]:

load '$(sPath)' autogenerate 1;

store [$(sPath)] into Parameter.txt (txt);


and your routine read this parameter and stored its output again into a txt-file which QV reads afterwards within a load.


- Marcus

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

In the QMC Server Security settings, you will have to check on both:

Allow macro execution on server

Allow unsafe macro execution on server

-Rob

jonastemin
Contributor II
Contributor II
Author

‌Botg of those are already checked

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

What error do you get in the script? Or no error but incorrect output?

jonastemin
Contributor II
Contributor II
Author

Thank you all for your input.

My conclusion is the QMC does not execute any macros.

Using EXECUTE and BAT to execute the script would have been possible but includes several steps that could potentially fail.

My solution (verified) is to use Qlik REST Connector;

Untitled.png

I needed to run a SQL Select statement and use WITH Connection to execute the POST command.