Tinderbox Forum

Find and sort tagged notes

Hello,

I would like to write an agent that would locate all notes with tags and then sort by tag and note content. How would I go about that?

Also what is the proper way to enter multiple tags and then have them pulled by tag - i.e Bob and Bill would be listed separately. Thanks!

Have you tried the Attribute Browser view?

Incidentally, welcome to the forum! To expand on my last, I don’t think you need an agent for the task as attribute browser was created for just this sort of task. The different ‘views’ are just that, different visualisations of the same underlying data. Using AB view doesn’t change the underlying data.

You can make an agent to find all data with tags. Assuming you are referring to data in the Tags system attribute, you can make an agent that finds notes with Tags data with this query:

$Tags!=""

You can also sort your agent on Tags via the Sort. But, Tags is a multi-value attribution, so on what are you assuming it will sort. I don’t think it’s predictable but likely it will use a note’s tags, listed in order they were added to the note. This might no be what you were inspected.

So, take the attached demo: tag-check.tbx (149.5 KB)

Note A has Tags ‘Nemesis’ and ‘Hubris’. Note B has no tags and Not C has ‘Hubris’.

Note that ‘Note A’ is listed twice as it has two tags. To lose that ‘[no value]’ category, we’ll add an agent with the query:

$Tags

This is short form of the same query I listed above— i.e. only match those notes that has a value for the Tags attribute. In the demo I’ve called the query “Must have tags”. Note how now only two notes are listed. Note B is omitted as it has no tags:

Thank you. This is very helpful.

1 Like