Detect if a Custom HTML Prompt is Running Asynchronously?

Nope. That ain't me. Bachelors, maybe. :joy:

I've discovered the best answer for my specific use case:

Here's what I wanted to do, which I am now in the process of coding: I wanted to run my Custom HTML Prompt two ways. The normal mode is synchronously, and everything is hunky-dory.

But I also wanted to be able to run it asynchronously, in which case it would act differently. This is not a normal occurrence, so I'm perfectly happy with setting a variable telling the prompt that it's running async.

But if it's running async, the prompt can't access local variables, which means I'd have to use a global variable, and I really didn't want to do that. (In fact, I'm in the process of cleaning up my KM variables, and this prompt will help with that, so no way was I going to add to the mess if I could help it!)

It turns out that even if the prompt is running async, Peter fills document.kmvar with all variables, including local ones. So all I have to do is something like this:

if (document.kmvar && document.kmvar.Local_ViAllVariables === "1")

The first check to see if document.kmvars is truthy probably isn't needed, but it doesn't hurt.

See Custom HTML Prompts :: Variable Value at Launch Time vs Value Now - #2 by DanThomas

2 Likes