Okay, I’ve quickly put together a full example for you.
First of all, here’s a keyboard enabled action group to download.
It contains four actions.
Choose - this action pops up the menu to choose from a list of other actions. To make this self-contained, I’ve included the three actions it allows you to choose from in this action group.
EG1 - this action inserts the current date in YYYY-MM-DD format.
EG2 - this action inserts the current date in MM-DD-YYYY format.
EG3 - this action inserts the current date in DD-MM-YYYY format.
When you select the Choose key it will pop-up a prompt with three buttons.
Note that the buttons display a description of what to do rather than the name of the action. I could have directly used the name of the action, but I figured this example could be more widely used and it might be better to be able to display different text that can be associated with the action. But likewise you could always display the name of the action.
When cancel is selected, an info message is popped up. When a button is selected, the associated action is run.
The script that does this is shown below. It takes a set of JSON where the key-value pairs are ‘button text-action name’ and then queues the selected action to run once the current one (the one displaying the prompt) completes.
//Define some JSON (key-value pairs), where the key is the button text to display
//and the value is the name of the action to run
let strActions = `
"Date YYYY-MM-DD" : "EG1",
"Date MM-DD-YYYY" : "EG2",
"Date DD-MM-YYYY" : "EG3"
//Send the JSON off to a function to display it to the user for selection and running
// Here are the functions that make it work
function promptButtonArray(p_strTitle, p_arrButtons)
//Set-up the base prompt
let promptButtonArray = Prompt.create();
promptButtonArray.title = p_strTitle;
//Create a button for each array item
let actionData = JSON.parse(p_jsonActions);
arrButtons = ;
//Build an array of JSON keys
for (key in actionData)
//Pop-up some choices for the action to run
let strResult = promptButtonArray("Run", arrButtons);
//If we get a selection, queue up the action associated with the selection to run next.
if (strResult == "") app.displayInfoMessage("Cancelled");
else app.queueAction(Action.find(actionData[strResult]), draft);
//Reactivate the editor in case it lost focus
You should just be able to duplicate and amend the JSON and any other parts of the action you wish for your own use, as many times as you wish.
Hope that helps.