Dynamic user prompt variables?

Is it possible to put a dynamic reference in a user prompt variable?

Variable "Prompt1" is set to "Receipts".
In the User Prompt variable field, there is "Prompt1".
When the prompt displays in the macro, "Receipts" is shown.
The user enters "$100".
The variable "Receipts" is filled with "$100."

It's as though "Prompt1" is a conduit to get the value "$100" into the variable "Receipts."

I realize there is a LOT wrong with the coding logic of what I just wrote. I have no idea how it would coded or if it's even possible in KM. I'm just trying to communicate the intent.

The idea is to have a dynamically changing list of prompts that can be fed into the user prompt action.

Yes. See How To Use Dynamic Variable Names.

Please don't do all the walking for me on this but can you get my brain just a couple steps closer. I did previously look at (and actually apply in another context) indirect variable references using token processing.

However, it seems to me that whatever I type in one of the "Prompt for User Input" variable fields (not the value side on the ride, but the field side on the left), that which I typed in the prompt on the left will be the variable name displayed, to be filled by the value on the right.

Below, you see in the image "Prompt1". I want "Prompt1" to display as "Receipts" when the Prompt for User Input action executes. Maybe later I want "Prompt1" to display as "Year," hence the dynamic nature of this.


I see no way to apply an indirect variable reference in this context.

If you want "Prompt1" to simply display as another name, but actually store the value in the "Prompt1" variable, then you can just use this format:

so, in your case it would be:

For more info see How to Hide a Variable Prefix in the Prompt for User Input.

Thanks for reply. My understanding is that by hiding the prefix...

Prompt1__Receipts would display as Receipts but would be stored in the variable Prompt1__Receipts.


I want the prompt to be fully dynamic.

So that at another execution the value "2018" would store in "Year."

I doubt this is possible, since the prompt field, inferred by the "v" in the corner of the field, only accepts variables.

You're correct, the Variable used in the Prompt for User Input Variable field can NOT be dynamic, only change what is displayed.

I suspect that to get what you want you will need to use a Custom HTML Prompt action.

If I'm correctly interpreting your intended use, you could accomplish the same thing by using a conditional that leads to different Prompt for User Input actions (each of which uses distinct input variables, like Receipts and Year), depending on the value of a variable that the conditional evaluates.

1 Like

The only way to make a fully dynamic prompt would be to generate the XML for the action yourself and then use Execute AppleScript to execute it.