Prompt with List from Dictionary

I would like to present the user with a dropdown list of all keys from a KM Dictionary and set the corresponding value of the selected key as a variable. Note that the values are multi-line text/paragraphs.

Seems like this question would have been asked/answered, but I'm not finding it. Help?

Hi @evanfuchs. If I'm interpreting your question correctly, this should help.


DOWNLOAD Macro File:
Get Dictionary Value for Selected Key.kmmacros (9.8 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

1 Like

This is great, @_jims. Thanks so much.

FYI, since I am working with an existing dictionary, I trimmed it down like so:

But the way you set it up helped me understand the actions I needed. Very helpful :slight_smile:

EDIT: BTW, the link break here created a extra blank lines in the variable local_Keys:

So I removed the \n and it still works fine.

1 Like

Yes, I agree with @evanfuchs this is terrific. One of my dictionaries has >100 key/value pairs, so I had to put an "All:" as the default search in the Prompt With List Action to actually display the keys. But even without that, the search works once you start typing, so I'm not sure if I will actually stick with displaying the keys for this dictionary or not.

1 Like

@evanfuchs, you're welcome; glad to help.

Yes, I understand. I just wanted to provide a standalone example for now and for future reference. :grinning:

Sorry, that was just an oversight on my part. I mistakenly pressed return after typing \n. The action should have ended immediately after the the newline (\n). Funny thing is, I think I somehow did that after my testing.

Hi @rolian, thanks. Glad you find it helpful.

Yes, IMHO, that behavior is confusing, particularly if one has a list that begins with fewer than 100 items and then over time grows larger. So, here's the method I've used in other macros to address that situation:

Group.kmactions (3.7 KB)

Group-image