Creating and maintaining lists that can be added to

I have used the action “Add To List” to create multiple Lists. My goal is to be able to continue to add various things to the specific lists I have created.
My problem is that when I go to a new draft , type something in and click on “Add to List, specific lists that I previously created disappear from the lists that come up as options.
Can anyone tell me why, what I am doing wrong?
Also, I am open to any suggestions on a better way to accomplish what I am trying to do which is simply have lists that I can continue to append or prepend new items to.

There are at least three such actions in the directory. That assumes you have not modified an existing action in any way or got an action from elsewhere. It is always useful to post a direct link to your action.

If you are using this action, then it uses the tag list to determine which drafts are lists available to add to. If you use any actions on those drafts that remove the tag, manually remove the tag, or move the draft (manually or through an action) to the trash, then that would remove the list from being visible to that specific action.

If you share the details of what you are doing, then probably.

fundamentally, whatever action you are using is identifying lists in some way and something else you are doing will be changing those original lists in some way as to stop the ‘Add to List’ action you are using from surfacing them as options.

I suspect the existing approach is fine for your needs assuming you have no other friction points to identify.

Adding the tag “list” was the solution. Thank you!

one more question regarding the lists I create in “Add to List”, is there a way to have the lists show up in descending alphabetical order?

Remember we still don’t know for sure exactly which action you are using… :person_shrugging:t2:

The Draft.query() function is no doubt being used to get the list of “list” drafts, an that has a sort parameter, but unfortunately only for dates.

Therefore you would need to sort the resulting array of draft objects by their title (I would specifically use draft.displayTitle to avoid things like Markdown syntax getting in the way), or you would need to sort it at the point of adding it to the prompt that is presumably being displayed to you to choose the list.

As long as you know a bit of JavaScript, this post should help you understand how you can sort the drafts based on a property of the draft.

Hope that helps.

Isn’t “Add to List” the action I am using?

As noted right at the start…

This assumes it is one from the public directory listing. There are unlisted actions, actions people create themselves, actions they modify “a little”…

An action’s name never uniquely identifies it to others.

Ah, okay. Understood. Unfortunately I do not remember which of the three actions it is. Is there a way to identify it?
Also, I have no Java script or any kind of coding knowledge so I’m a real novice here and struggling with some of this program. Thanks for bearing with me and trying to help!

Probably a safe bet you are using the version of the action from this tip.

That action builds the list of available “list” drafts in the following code in the script:

// finds existing "list" drafts
function getListDrafts() {
	let drafts = Draft.query("", "all", [tag])
	return drafts
}

The Draft.query function can also take sorting parameters. If you altered that code to be:

// finds existing "list" drafts
function getListDrafts() {
	let drafts = Draft.query("", "all", [tag], [], "name")
	return drafts
}

It would sort those by the text content before displaying them in the prompt.

The documentation for the query() function only lists “created”, “modified”, and “accessed” as options for the sort parameter.

That was the basis for sorting by an object property I linked to above.

Is “name” the equivalent of the title, the displayTitle, or something else?

I was intrigued, so I created some title only notes in the order: “Apple”, “# Banana”, “Clementine”, “# Durian”, “# Fig”, “Elderberry”. i.e. not quite alphabetical and with a mix of Markdown heading syntax and plain text.

Running the query with no sorting and outputting each draft title on a new line, I get the titles in chronological order.

let aDrafts = Draft.query("", "all", ["testing"]);
let astrDrafts = aDrafts.map(d => d.title);
alert(astrDrafts.join("\n"));

This returns the results in the default sort order of when they were created.

Putting name as the sort parameter changes the order:

let aDrafts = Draft.query("", "all", ["testing"], [], "name");
let astrDrafts = aDrafts.map(d => d.title);
alert(astrDrafts.join("\n"));

The Markdown headings are grouped and sorted, as are the non-Markdown headings. It therefore looks like it is sorting alphabetically on the draft title as opposed to the display title.

Just to test that it wasn’t a change based on a non-standard input (i.e. name is not listed in the docs or the code definition file as a valid sort option), I tried with a definitively non-standard sort option and it also gave the default (first above) result.

let aDrafts = Draft.query("", "all", ["testing"], [], "this_is_an_invalid_option");
let astrDrafts = aDrafts.map(d => d.title);
alert(astrDrafts.join("\n"));

 
Not an entirely definitive set of tests of course, but I figured that actually, it wasn’t much effort to do at least a quick check myself.

Looks like I need to update the docs. The sort properly should be marked as sortBy type for the correct options. See sortBy ref

1 Like

I started using Drafts when I learned that I could create lists in Evernote and prepend to notes using Drafts. Since it appears that this process doesn’t work well anymore I started trying to learn more about Drafts to see if I could figure out another way of maintaining lists on some other note taking app.
After diving in and learning more about Drafts, it seems like maintaining those lists in Drafts could be a good alternative but it is has become obvious that my lack of knowledge about programming limits me and I could use some help. Is there anyone out there that I could pay for help. I don’t think it would be a lot of work for someone knowing what they are doing. I appreciate everyone’s help with my questions and I continue to learn more about Drafts but it is obvious that I need help with this project. Thanks!

Personally, I think I’d store lists somewhere else. JSON in Data Jar would be my best guess.

I think it might be worth a look at Dynalist for keeping lists, even if only to practise - if you want something other than Drafts. I keep lists in Dynalist but mainly because I share them and without the need to share I think I would stick with Drafts and export to Obsidian where markdown files can be edited and backed up easily.