Restricting input input

I have a shortcut that asks for text and then runs off to my mail server to do some searches of that text. Since the text is passed to grep, I want it to be constrained to a single line, but the ask for input action allows free form text. This also means that “Return” doesn’t submit the text. Is there a better Where are you?

Also, when setting up a dictionary and then choose from list, it shows both the key and the value. How could I just show the key? Can I create a separate list to choose from that is then mapped to the dictionary in a way that isn’t visible when the shortcut runs?

So if you use Ask When Run you and the right action you can restrict to one line. Similarly you could ignore anything but the first line, for scripting change newline characters into command concatenations, etc. The issue is the dismissal via the ‘Done’. There’s no option in the app unless you are using an external keyboard in which case you can use CMD + RETURN. Otherwise I think you’d have to spawn out to another app to do you single line of capture with just return to return the data.

As for just listing keys from the dictionary, you can do that like this.

Hope that helps.

I tried that, but then the action gets passed the key, and not the value. I want the shortcut to let me choose based on the key, but then pass the value.

For example, I have a dictionary with

Key     Value
Kids    "Bob, Mary, Sue, Jack, Tom"
Adults  "Alice, Meredith, Lindsay, George"

When I get the list to chose, I want to tap “Kids” and then in the {Text} field following I want {Chosen Item:Value} blah blah blah {Chosen Item:Key}

But instead I get nothing for either Chosen Item Value unless I change it from get as dictionary to get as text, in which case I only get the key.

Hopefully this will make it a bit clearer.

https://www.icloud.com/shortcuts/4c1a462da3f34607bc691851b503ccf2

Thanks, that does what I want.

That is to say, taking what you wrote I have a working shortcut that does what I want, but I don’t know why {Get Variable %Dictionary%} makes the whole thing work.

That’s just grabbing the dictionary so you can reference it. For example, with a Get Dictionary Value action whch takes a dictionary as input.

Right, but why doesn’t it work with a magic variable of the Dictionary (It gives an error about not being able to get the dictionary or somesuch).

I’m afraid I don’t follow.

The Get Variable use of Dictionary is actually the use of a magic variable. I didn’t assign the Dictionary to a variable using Set Variable or Add to Variable. When specifing what variable to use in the Get Variable, I used ‘Select Magic Variable’ to select the action output directly.

If you were embedding a Dictionary Magic Variable with key selection into say a Text acion then you wouldn’t be able to dynamically specify the attribute - i.e. the key name; as you have to specify the attribute name as a text string, not as any type of variable.

Could you clarify your query further?