Prompt Command - use variable as default value

Thanks for the new Prompt command!

I’m trying to use a variable as the default value. Is that possible? If it is, can you tell me what I’m doing wrong in this sample?

{
  "Command": "prompt",
  "Target": "Enter Task ID@${globalTaskSearch}",
  "Value": "globalTaskSearch"
}

SHORT BACKGROUND: Before the Prompt was available, I was storing the Clipboard value to the globalTaskSearch variable. So now, I want to leave the clipboard value and let the user override it if needed. This didn’t work either.

{
  "Command": "prompt",
  "Target": "Enter Task ID@storedVars['!clipboard'] .trim()",
  "Value": "globalTaskSearch"
}

If it’s not possible, I will probably switch to using the Prompt command and ignore the clipboard value.

Thanks

In my test I can use a variable as default value:

  • store | 123 | var
  • prompt | hello@${var} | var2

Does this work for you? Maybe you forgot to define your variable? :wink:

{
  "Command": "store",
  "Target": "123",
  "Value": "ddd"
},
{
  "Command": "prompt",
  "Target": "hello abc@${ddd}",
  "Value": "kkk"
},

Hi @ulrich,

I must’ve been doing something wrong. Using variables does work fine.

If I use your example, the default value showing up on the prompt was ${ddd} instead of 123 (so in my case ${globalTaskSearch} was showing up instead of the clipboard value I stroed in the variable).

However, I tried your code now and re-did my code and both work fine. I even get null come up if the clipboard is empty. I wish I had saved the code I posted earlier so I could see what I did wrong. Funny thing is I cut and paste the code into the forum and it looks fine.

Anyway, thanks for the very prompt response.

@ulrich by any chance for the text can we include html code
to format the text for the question?

Secondly, can we make it so that the Target text auto deletes when typing in on it, instead of having to delete it?

1 Like

@admin @ulrich
please, as requested above. Especially:

Secondly, can we make it so that the Target text auto deletes when typing in on it, instead of having to delete it?

Also, the default value using @ fails with “Invalid attempt to destructure non-iterable instance” if the default is blank/null. This shouldn’t be the case, since variables can be used as the default value and an empty value may very well be the expected case. For example, if we’re pulling data from a source where some fields may be empty.

I can get around it with clumsy if statements but it would be much better to handle blanks in the back end (just ignore @ if there’s nothing after it).

1 Like