Hi @Josh_Whitchurch,
The default setting won't allow any commands, that's why your workflow isn't working.
However, you could accomplish something similar with keyed lists.
Let's start with the basic structure.
Below, you can see a keyed list consisting of 6 items, each one having a key and corresponding value.
The value for the sixth item is the variable other
, which is populated by whatever I insert in the text field (which shows up when I choose "other" in the dropdown).
{list=["option 1":"result 1", "option 2":"result 2", "option 3":"result 3", "option 4":"result 4", "option 5":"result 5", "other":other]}
{formmenu: name=choice; values={=keys(list)}}{if: choice == "other"}{formtext: name=other}{endif}
{=list[choice]}
Now, let's apply it to a scenario where we're checking for one of a number of strings.
{note: preview=no}
{list=["name 1":"ID 1", "ID 2":"result 2", "name 3":"ID 3", "name 4":"ID 4", "name 5":"ID 5"]}
{id=catch(extractregex(sitecontent, "Name:\s*(.*)"), other)}
{endnote: trim=right}
{note}
This text field represents what you'd be extracting from the website:
{formparagraph: cols=50; name=sitecontent; default=Name:}
{endnote: trim=right}
{=id if id <> "" else "No name found"}: {=catch(list[id], "No corresponding ID")}
Here's a more advanced version. In this case, if the regex extracts anything that does not match one of the keys in the list, you'll get two text fields to input the name and ID manually.
{note: preview=no}
{list=["name 1":"ID 1", "name 2":"ID 2", "name 3":"ID 3", "name 4":"ID 4", "name 5":"ID 5"]}
{id=catch(extractregex(sitecontent, "Name:\s*(.*)"), other)}
{endnote: trim=right}
{note}
This text field represents what you'd be extracting from the website:
{formparagraph: cols=50; name=sitecontent; default=Name:}
{if: NOT includes(keys(list), id)}
No name matches.
Please enter name and ID manually.
Custom name: {formtext: name=customname; default=N/A} {if: customname == "" OR customname == "N/A"}{error: Please specify a name; block=yes}{endif}
Custom ID: {formtext: name=customid; default=N/A} {if: customid == "" OR customid == "N/A"}{error: Please specify an ID; block=yes}{endif}
{endif}
{endnote: trim=right}
{=concat(id&": "&list[id]) if includes(keys(list), id) else concat(customname&": "&customid)}
If you wanted, you could take it a step further (assuming the platform you're using allows it) and use {urlsend}
to send the contents of the text fields to a google sheet, so you can track new name/ID combinations. And then instead of specifying the name/ID pairs inside the snippet, you could use {urlload}
to load them from the google sheet.
Would this work for you?