Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rzenere_avvale
Partner - Specialist II
Partner - Specialist II

JScript: WaitForIdle or equivalent

Hi everyone,

I'm looking for a way to make the WaitForIdle (or equivalent function, even a custom one) work on a JScript macro.

What I'm trying to achieve is to pause the application (not make it "sleep", as I've already done with custom code) in order to select a value on a field and give time to the application to "update the layout" with the selection before taking a screenshot.

Currently with the lone sleep the screenshot is taken before I can see the layout update.

Do you have any hint about how to do this in JScript?

1 Solution

Accepted Solutions
rzenere_avvale
Partner - Specialist II
Partner - Specialist II
Author

Sorry for the very late answer, I had literally no time

Anyway, this is what I discovered:

  • Upgrading to QlikView 11.20 SR13 the actions are executed in the right order (so they truely wait till the end of the previous action). Anyway this solved my problem only partially, because from batch the macro wasn't working properly once again. Calling the right way the WaitForIdle (see below) solved my problem
    Side note: at the time I wrote the question I was trying the macro with QlikView 11.20 SR7 and SR12.
  • The right way to call the WaitForIdle is this: Application.WaitForIdle(). My mistake was trying to call it using the ActiveDocument...


Thanks to everyone for the help!

View solution in original post

12 Replies
sinanozdemir
Specialist III
Specialist III

It has been a while I didn't code in JScript, but I think you can use if you haven't already tried it:

setTimeout(function() {alert("take your screenshot");}, 1000);

sinanozdemir
Specialist III
Specialist III

You can also look into using WinJS libraries:

https://msdn.microsoft.com/en-us/library/windows/apps/br229706.aspx

rzenere_avvale
Partner - Specialist II
Partner - Specialist II
Author

Hi Sinan, thanks for your reply

I've already tried that (only difference is the Application.Msgbox instead of the alert) but it's not working... When I use it opens the Edit Module and does nothing at all!

rzenere_avvale
Partner - Specialist II
Partner - Specialist II
Author

I'm not sure about how to use them, using directly

WinJS.Application.stop();

won't work...

Do I need to import anything? If not, could you make a working example, please?

thanks

sinanozdemir
Specialist III
Specialist III

I believe you need to download WinJS from this link WinJS: Windows Library for JavaScript - Windows app development

Apart from this, the only way is to use setTimeout() as far as I know.

rzenere_avvale
Partner - Specialist II
Partner - Specialist II
Author

Tried that, but including it in the module gave me many errors: on the WinJS base/ui file there are many strings that ends with a ",", which I'm not sure about... Of course the parser gives me error, and I think they are wrong too... but I hope they left them there for a purpose

Still no luck with setTimeout, but thanks for trying

Let's see if anybody else has an idea/workaround for my problem

petter
Partner - Champion III
Partner - Champion III

Here is how you can use InputBox and MsgBox from JScript:

// JScript

function Test()

{    

     personName = qvlib.InputBox("What is you name?")

     msg = "Hello " + personName + " !"

     qvlib.MsgBox(msg)

}

petter
Partner - Champion III
Partner - Champion III

Try this:

function Test()

{

  qvlib.MsgBox('Started.');

  app = ActiveDocument.GetApplication();

  qvlib.MsgBox( '[' + app.OSName() + ']' );

  app.WaitForIdle();

  qvlib.MsgBox('Ended.');

}

rzenere_avvale
Partner - Specialist II
Partner - Specialist II
Author

Hi Petter, thanks for your reply,

I've tried it and it works, but I don't think this example is the best one... When you use a MsgBox or something else where you need the user to execute an action (in this situation click the "ok" button to proceed with the execution of the macro) you stop the execution, so it's not like having it scheduled...

Anyway I found the solution to my problem, I'll post it later