How to set variable "other" with text dialog #333
Replies: 1 comment 4 replies
-
Currently (i.e., app version 2.30.0), it is not possible to achieve the desired behavior with variables alone. The order in which variables are resolved is sort of like a queue. First all the primary variables will be resolved, i.e., the ones used by the shortcut directly, e.g. as part of its URL. If one of those variables then references another variable which has not been resolved yet, it will be added to the queue and resolved once all other other variables before it in the queue have been resolved. I will see if I can perhaps change this behavior in the app in a future version, to make it more intuitive, but I can't make any promises as this might lead to breaking changes which I want to avoid. As a workaround however, you could achieve this by switching from using variables over to using the Scripting feature, as that one gives you much more control over the flow. However, it requires more effort and technical expertise. To make a very simple example, here's a snippet of Javascript code with which how you might achieve your goal: let mySelection = showSelection([
'A', 'B', 'C', 'Other',
]);
if (!mySelection) {
// cancel execution of the shortcut if the user cancelled the popup dialog
abort();
}
if (mySelection == 'Other') {
mySelection = prompt('Others');
}
if (!mySelection) {
// cancel execution of the shortcut if the user cancelled the popup dialog
abort();
}
// at the end, we store the value back into an actual variable (i.e., app variable, not JS variable), so that we can use it in the shortcut.
setVariable('test', mySelection); You'll find more information about Scripting and the various ways you can prompt for user input here: https://http-shortcuts.rmy.ch/scripting#user-interaction Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I am using MultipleChoiceSelection as a variable in my application, and I have added a "Others" option at the end that allows text input.
When I set a text variable for the value of "Others", I can now enter text when "Others" is selected.
However, when I use a shortcut that has multiple dialogs in one shortcut, the "Others" input screen comes up last.
I would like to set it so that when "Others" is selected, the input screen appears in the dialog that immediately follows.
I would appreciate it if you could tell me if this problem can be solved by just setting a variable or if I have to write JavaScript to set it up.
I have a video up for testing, please watch.
https://www.youtube.com/shorts/y5JDXgXBHhY
thank you
Beta Was this translation helpful? Give feedback.
All reactions