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

No heading so that’s not a problem but some idea of how to modify the script to prepend would be good.

Thanks!

I updated my tweaked version of this action:

  • new Add option to append or prepend items to a list.

  • Collect list names from tagged drafts.

  • Create new lists inside the action.

Action directory: https://actions.getdrafts.com/a/1Gd

8 Likes

Can you add in the description and code comments that to identify a list, the set tag (e.g. lists) and ## header is required?

Thanks for the fork!

2 Likes

Hi - This worked great for me for a while - not sure what I did, but now when I try to add something to a list, it creates a NEW list whose only item is the Draft just acted upon…
Any thoughts what might be causing this? I’m suspecting it may have something to do w the fact that the old lists have been archived; so when I go to add to them, it creates a new list in the Inbox; however, I don’t want the lists sitting in my Inbox… but rather out of sight, out of mind…
Any help would be welcomed!

The action is only looking for list drafts in the inbox.

I have a tweaked version of the action that has a few additional features. I updated it to look in the inbox, flagged, and archive which might work for you.

Action directory: https://actions.getdrafts.com/a/1Gd

4 Likes

Thanks so much for your quick response - I’ll give it a try:)

In my forked version I added an option to view the list after successfully adding an item. The default setting is false for backwards compatibility.

// set this option to `true` to view
// the list after adding an item.
const viewListAfterSuccess = false;

Action directory: https://actions.getdrafts.com/a/1Gd

3 Likes

Is there anyway to invoke this with a Siri command

I would love to be able to say add grapes to my grocery list in drafts

1 Like

You could theoretically do that in the upcoming release of i*OS and Drafts I believe.

I use this to keep lists of books, movies and tv shows that I want to read/see. I have been searching for a way to add the date when I check off an item on the list. So far haven’t found anything that meets that description. Can this functionality be added easily with a script?

You can’t trigger an action from checking an inline check box, but you could use an action to check the box on the current line and append the date to the end. You could keep it on your action bar (above the keyboard) for easy access.

One thing you can do is use TextExpander. They have a lot of default date formats. For example, the one I use is dld. That gives me 20210328, which is the date format I prefer for filing. However, there are a lot of others with their own shortcuts.

Yes, this makes sense to me. Thank you. When I have a chance I will come back to this to see if I can get it working.

Is there a way to “Add to List” a selection as opposed to a full draft? Sometimes I have taken notes and just want a selection from my notes added to a list.

Yes, this is certainly possible. Rather than referencing the content property of a draft, you would reference the selected text of the editor.

Try changing this code in the original action…

// grab current draft
const currentContent = draft.content.trim();

…to this…

// grab current draft text selection
const currentContent = editor.getSelectedText().trim();

Hope that helps.

1 Like

@sylumer’s suggestion is great, but I might suggest a slight tweak. If you replace the line he called out with the below, the action would continue to work both ways, because the [[selection]] template tag returns the full text of the draft if their is no current selection – therefore you would not need two separate actions for use on full text versus current selection:

// grab current draft
const currentContent = draft.processTemplate("[[selection]]");
4 Likes

It worked perfectly. Thank you!

This action is working great for me. I have one more wish - is it possible for the draft that I am pulling the selection from to stay as the current draft even after the selection is made and moved to the list (I generally have several selections that I make from a single draft)? I appreciate the help. I am really enjoying drafts.

1 Like

Try changing the “After Success” setting for the action from “Archive” to “Nothing”.

1 Like

Thank you! That did the trick.