TIP: Quickly Manage Running Lists with the "Add to List" Action

UPDATE:2022-12-15 Re-written with more complete details and example workspace.

This tip covers using Drafts to keep up with running lists. These are the type of lists you might keep of movies or TV shows you want to watch, books you have been recommended, or things like errands you need to run, or stuff you need to grab at the store.

In my personal use, I have lists for movies, books, and also specific stores, like a “Hardware Store” list to remember those pesky little items you always forget when you get there.

The great advantage of using this action and workflow, is that adding new items to your lists becomes trivial. No need to open a notes app, browse around to find the right “Movies” note, scroll to the right place, etc. Instead, just pull out your phone, type the item, run the action, and put your phone away.

Start with the brief demo video showing this workflow in use. The remainder of the article covers installing the example action and related workspace, and explains how the system works in greater detail.

Demo Video

Install the “Add to List” Action

Start by installing the example action from the Drafts Directory:

Use the “Install” button on that page on any device with Drafts installed. Follow prompts in Drafts to assign an action group for the action. It can be moved later.

Using the Action

Follow these steps to test out the action:

  • Create a new draft, and type something brief in just the first line of the draft. Let say “Jaws” or the name of some other movie.
  • Run the “Add to List” action.
  • Since this is the first time you have run the action, you will get a prompt asking you to enter the name of a list. Enter “Movies”
  • Hit the “Create New List” button in the prompt.

You should then receive a confirmation banner say “1 item added to list” and you should be looking at a new, empty draft in the editor.

Now do those steps again with a different movie name. The process should be mostly the same, other than the prompt will now also offer the “Movies” list as an existing list to select.

You may be wondering what happened; let’s review what the action did:

  • Looks for any existing drafts with the tag “list”, those are offered as options in the prompt
  • Ask you which list to add to, or if you want to create a new one.
  • If creating a new list, create a new draft with the title you provide, with the tag “list” assigned, in the archive (so your lists won’t clutter up the inbox)…otherwise, select the existing draft based on your selection.
  • Take the lines in your current draft, convert them to list items (adding - [ ] at the beginning). In our example, we only added a single item, but if you put multiple items, each on its own line, they will all be added.
  • Append them to the list draft.
  • Archive the current draft (this is done by the “After Success” settings on the action - you could change this option to trash the draft, if preferred).

Now, anytime you have a new thing you want in a list, quickly pop open Drafts, type just that thing, run this action, and it will be filed away for later in your lists.

Using Your Lists

Now that we have an easy way to capture items to our set of lists, how do we use the lists?

Well, to begin with, the lists created by this action are just drafts. The only distinction being that they are assigned the tag “list”. Like any other drafts in your note store, you can open them in the editor, make changes, check things off, remove items, add items directly to the list, etc. You can search for “Movies” in quick search, and get to your movie list.

But, if you start to get several lists setup and want a quick way to access and review them, the best way to do that is with a workspace.

Install the “Lists” Workspace

You could create your own, but to expedite the process, install the “Lists” example workspace. Workspaces apply sets of filters and settings to the draft list, and this one focuses the list to show only your “List” drafts.

After installing, apply the workspace to your draft list by selecting it from the workspace menu above the list. You may wish to customize aspects of this workspace to your liking, but the key elements of the workspace as configured:

  • Filter the list to show only drafts with the tag “list” assigned.
  • When applied, automatically switch to the “Archive” tab. The action above creates lists in the archive to avoid cluttering the inbox, so this is a convenience option.
  • Sort the list by text so your lists are in name order.

The “Open List” Action

Alternate, you can also install and use the below “Open List” example action:

This action opens a prompt for you to select a list, and opens it in the editor. This is a quick way to jump to a specific list.

The “Open List” action works especially well with Home Screen widgets. Assign an item in a Drafts Grid widget this action, and you have a shortcut to open Drafts directly to any of your lists quickly.

General Related Tips

  • If you would like to pre-create the lists you plan to use, just create new drafts, assign the tag “list”, and give them a Markdown heading title in the first line of the draft. They will then be available as options to the action.
13 Likes

Where do I find the scripts so they can be edited?

@Verity
In the Drafts Directory.

Tap “+” to add a new action and select “Visit Directory”; at the moment, if you select “Recent Actions” on the resulting webpage, “Add to list” is at the top, or just search for it. Tap on the action to open it’s description.

Click on the “Install” Button and select the group to install it into in your Drafts. You can then edit it in your action list by swiping right on the action name and tapping “Edit”.

Hope this helps.

Swipe to the right on an action to get to its “Edit” screen. Details here.

You’ll need to tap on the steps, then the script step…the lines you are looking to modify are at the top of the script and look like:

// EDIT THIS
// setup categories available
const categories = ["Movies", "TV Shows", "Blog Ideas"];

// EDIT TAG
// tag to assign to list drafts
const listTag = "lists";

If you are not familiar with scripting it can look a little intimidating, but it’s not too bad. The categories is an array, and is just a comma-separated list of quoted strings. You can have as many or as few categories as needed.

1 Like

Thank you, both of you :slight_smile: I reckon I could get the hang of that!

Thanks for this script, It will definitely see a lot of use… one question though: is there any way to add multiple items at once? Example: if I am with a friend who says “you really need to see x, y, and z” how can I modify the script to accept data points from multiple successive lines?
Thanks in advance,

Javascript’s standard Array.map can take an existing function on a single string, and apply it to a whole list of strings.

For example:

d.content = d.content + currentContent
.split('\n')
.map(x => '- [ ] ' + x)
.join('\n'),

Used in context:

Full source for an Add *All* to List variant – click to expand
(() => {
    'use strict';

    // Based on an original script by @agiletortoise

    /*
      Ask for a category, and append to a 
      tagged list for that category
    */

    // EDIT THIS
    // setup categories available
    const
        categories = ['Movies', 'TV Shows', 'Blog Ideas'],

        // EDIT TAG
        // tag to assign to list drafts
        listTag = 'lists',

        // grab text
        currentContent = draft.content.trim(),

        // A prompt for selecting an item from a list.
        p = categories.reduce(

            // Accumulator updates - a button added for 
            // each category in the list:
            (prompt, buttonName) => {
                prompt.addButton(buttonName);
                return prompt;
            },

            // Initial accumulator: a prompt with properties:
            Object.assign(
                Prompt.create(), {
                    title: 'Select list:',
                    message: 'Ask for a category, and append' +
                        ' to a tagged list for that category',
                    isCancellable: true
                }
            )
        );

    return p.show() ? (() => {
        const
            category = p.buttonPressed,

            // query for list drafts...
            drafts = Draft.query(category, 'inbox', [listTag]),

            // index of first draft that matches a condition
            iDraft = drafts.findIndex(
                draft => draft.content.startsWith('## ' + category)
            ),

            d = iDraft !== -1 ? (
                drafts[iDraft]
            ) : Object.assign(
                Draft.create(), {
                    content: '## ' + category + '\n\n'
                });

        return (
            // tag and update content
            d.addTag(listTag),

            d.content = d.content + currentContent
            .split('\n')
            .map(x => '- [ ] ' + x)
            .join('\n'),

            d.update(),
            console.log(true)
        );
    })() : (
        context.cancel(),
        console.log(false)
    );
})();
4 Likes

Is there a way to cross off [x] items e.g. from a shopping list?

1 Like

They are tappable task marks. Is that what you are asking?

Experimenting with a version that:

  • collects the category names from the top of the list drafts
  • adds a prompt to create a new category / list draft

Not listed, so it doesn’t step on Greg’s example, but you can look at it here.

1 Like

Yes I have those. But to delete the ones done. I.e. in a shopping list it deletes the items you have picked up leaving the ones you need, when you next open the note.
Hope that makes sense.

Great addition. Thanks.

This is great, thanks!

You can modify this action that I created which moves the done tasks to the bottom of the list to do what you need.

2 Likes

Re the final lines of that action

begin = begin.slice(0,-1);
end = end.slice(0,-1);
editor.setText(begin + "\n" + end);
d.update;
editor.focus(d);
  • My understanding is that update is a method, so presumably it needs to be called with a trailing parentheses ? d.update()

(rather than just evaluating to a function value ?)

1 Like

Is it possible to run this script without the check boxes?

You know what I’d like here? I’d like the action to turn each listed item into a tappable link to search Google or Duck Duck Go so when I later come back to the list it’s easy to look up whatever the thing is.

1 Like

This great thanks appreciated.

Is there a way to adapt this script to prepend rather than append text to an existing draft? I keep a running list of favourite quotes with the most recent at the top. At the moment when I open the draft each time and the cursor default to the end of the text. I’ve had a look but coding isn’ t my strong point!

Thanks in advance.

Euan

Yes, it’s certainly possible to alter the script to put new list items at the top. A little more complex if you want to maintain the heading, since the script would have to local the right insertion point, not just tack text on the top.

Not restoring the last cursor position is a bug in the current release which will be fixed in the next update.

1 Like