Action

process Drafts in INBOX

Posted by @FlohGro, Last update over 2 years ago

UPDATES

over 2 years ago

added option to cancel the execution completely

show all updates...

over 2 years ago

added option to cancel the execution completely

almost 3 years ago

description update

created by @FlohGro / more on my Blog

process Drafts in INBOX

This action can be used to quickly sort out your INBOX workspace.

The script will query your drafts from the defined workspace and ask you which of your action you want to run on the draft

The actions you want to run on the drafts in your inbox workspace are customizable.

The action was inspired by this post in the drafts forum: TIP: Focus Your Inbox with an “Untagged” which recommends to create a separate workspace which is your actual „inbox“. You can e.g. define a workspace which filters for untaggged drafts in your library.

The Action was published in this post in the forum: Process Drafts in INBOX Action

[Configuration]

Before running the action you have to adapt the name of your „inbox“ workspace. Therefore you need to change the following line in the script step of the action: let inboxWorkspaceName = "INBOX"; replace INBOX with the name of your inbox workspace (if you chose another one).

Next you need to change the actions you maybe want to run on the drafts in your inbox. To do so, you have to edit the actionArray in the script. By default this array looks like this:

let actionArray = [
  ['CANCEL', 'cancelExecutionOfProcessInboxAction'],
  ['skip', ''],
  ['✅ Todoist inbox lines', 'INBOX line's'],
  ['🔗 Todoist URL Task', 'Draft URL Task'],
  ['🗂 Bookmark to DEVONthink', 'bookmark to DEVONthink'],
  ['⌨️ Markdown to DEVONthink', 'Markdown to DEVONthink CB'],
  ['🏷 add tags from category', 'add tag from category'],
  ['🗑 trash', 'trash']
];

Every element in the array (e.g. „['🗑 trash', 'trash‘]“) contains two strings. the first string e.g. 🗑 trash defines how the action is displayed in the prompt. The second string e.g. trash contains the actual name of the action which shall be run.

To insert your own actions you can choose a name - how they should be displayed in the prompt and insert the action name in the second string. You can replace the existing ones by your own action or use the templates which are commented out ['', ''], by removing the slashes in front of them and insert your own name and the action name between the quotation marks.

I recommend to keep the line ['skip', ''], inside the action to enable you to skip a draft and don’t run an action on it.
The line ['CANCEL', 'cancelExecutionOfProcessInboxAction'], can be deleted if you don‘t need the option to completely cancel the execution of the process INBOX action without skipping each draft in your inbox.

[Usage]

Drafts is my main INBOX for everything text related. Whether its a link from a webpage, a quick thought, a task or any other note I want to save. I want to stay Inbox Zero and that’s where this action speeds the things up a lot. I just run it and I can decide just with the title of the draft what needs to be done with it (e.g. push it to the todoist inbox, bookmark the link in DEVONthink and so on). The actions I select to run on the draft will actually be executed after the „process Drafts in INBOX“ action one after the other.


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

Buy Me A Coffee

Steps

  • script

    // created by @FlohGro
    
    // process drafts from INBOX
    // ----------------------------------------------------
    // START OF USER DEFINITIONS
    
    // define the name of your inbox workspace
    let inboxWorkspaceName = "INBOX";
    
    // declare "display names" (for the prompt) and "action names" (from your Actions) in an array:
    // the last pair does not need a "," after the [] brackets!s
    let actionArray = [
      ['CANCEL', 'cancelExecutionOfProcessInbox'],
      ['skip', ''],
      ['✅ Todoist inbox lines', 'INBOX line’s'],
      ['🔗 Todoist URL Task', 'Draft URL Task'],
      ['🗂 Bookmark to DEVONthink', 'bookmark to DEVONthink'],
      ['⌨️ Markdown to DEVONthink', 'Markdown to DEVONthink CB'],
      ['🏷 add tags from category', 'add tag from category'],
      ['🗑 trash', 'trash']
      //   ['', ''],
      //   ['', ''],
      //   ['', ''],
    ];
    
    // END OF USER DEFINITIONS
    // ----------------------------------------------------
    
    let actionMap = new Map(actionArray);
    // - get drafts from INBOX Workspace
    let inboxWorkspace = Workspace.find(inboxWorkspaceName);
    let inboxDrafts = inboxWorkspace.query("all");
    
    // loop through every draft (show title and prompt for action on it)
    
    for (inboxDraft of inboxDrafts) {
      let actionPrompt = new Prompt();
      actionPrompt.title = "process draft"
      actionPrompt.message = "draft: " + inboxDraft.displayTitle;
    
      // add button for all elements in the actionMap
    
      actionMap.forEach(function(value, key) {
        actionPrompt.addButton(key, value);
      })
      actionPrompt.isCancellable = false;
      actionPrompt.show();
    
      let selectedAction = actionPrompt.buttonPressed;
    
      if (selectedAction == '') {
        // no action for the given name
      } else if (selectedAction == 'cancelExecutionOfProcessInbox'){
        break;
      }else {
        let action = Action.find(selectedAction);
        app.queueAction(action, inboxDraft);
      }
    
    }

Options

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