Action

Launch Action

Posted by FlohGro, Last update over 2 years ago

UPDATES

over 3 years ago

Fixed always the same action was executed

created by @FlohGro / more on my Blog

Launch Action

This action can be used as a launcher of Actions from an ActionGroup in Drafts.

You can configure the action to always show the actions from one Action Group in a prompt - the selected action will be launched.

If you don’t specify an Action Group the action will first present a prompt where you have to select the Action Group and afterwards prompt for the Action you want to run.

[Configuration]

To configure the action to use a specific Action Group you have to edit the „Define Template Step“ in the action. In the Text field „Template“ replace undefined with the name of the Action Group which shall be used by the action.

To let the action query for all Action Groups set it back to „undefined“.

If you want to use this action for several Action Groups, just duplicate it and configure the names of the Action Groups.

I recommend to add a suffix to the action name to identify the Action Group you configured.

[Usage]

Use this Action to quickly launch an action from a specific Action Group or all your Action Groups.

You can assign it to a keyboard shortcut or add it to an action bar.


If you find this useful and want to support me you can

Buy Me A Coffee

Steps

  • defineTemplateTag

    name
    ACTION_GROUP_NAME
    template
    undefined
  • script

    // ActionGroup Picker
    
    let predefinedActionGroupName = draft.processTemplate("[[ACTION_GROUP_NAME]]")
    
    
    let usePredefinedActionGroup = false;
    if(predefinedActionGroupName != "undefined"){
    	usePredefinedActionGroup = true;
    }
    
    var actionGroupName = ""
    if (usePredefinedActionGroup) {
        actionGroupName = predefinedActionGroupName
    } else {
        let actionGroups = ActionGroup.getAll()
    
    
        let p = Prompt.create();
        p.title = "select Action Group";
    
        for (var aGroup of actionGroups) {
            p.addButton(aGroup.name);
        }
        p.isCancellable = false
    
        if (p.show()) {
            actionGroupName = p.buttonPressed
        }
    }
    
    var actionGroup = ActionGroup.find(actionGroupName)
    
    if (actionGroup) {
    
        let actions = actionGroup.actions
    
        let p = Prompt.create();
        p.title = "select action";
    
        for (var action of actions) {
            p.addButton(action.name,action);
        }
        var con = p.show();
    
        if (con) {
            app.queueAction(p.buttonPressed, draft);
        } else {
            context.cancel();
        }
    
    } else {
      app.displayErrorMessage("ActionGroup \"" + actionGroupName + "\" not found!");
      context.fail();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.