Dataview Note Inbox Snippet

I love the idea of using map notes to organize my thinking, but I found that trying to manually curate them was really stressful. While backlinks and tags are helpful for seeing everything that might belong on a given map note, it was difficult for me to easily figure out which notes I had already added to the map and which were still unlinked.

So, I came up with a dataview plugin solution that produces an “inbox” table for a note listing all the notes that link to the note but are NOT current linked within the note.

table file.cday as "Date Created", file.tags as Tags
from "YOUR NOTE FOLDER" 
and (#YOURTAGS)
and [[YOUR NOTE]] 
and !outgoing([[YOUR NOTE]]) 
sort file.cday desc

So the way this works is that it lists all notes from YOUR NOTE FOLDER with YOURTAGS that have links to YOUR NOTE but are not already linked within YOUR NOTE.

Example

Here’s a picture of how it works in practice. I created a Note called “TEST MAP NOTE” and three “Test Notes,” putting a wikilink to [[Test Map Note]] in each note.

On the left is the editor view of [[Test Map Note]] which contains the snippet code. Note that, outside the snippet, I have linked Test Note 3 directly within the map.

Within the snippet:

  • "TESTING" is the folder I made to store the basic notes I write, which I link to the map note.
  • Additionally, each test note is tagged with #test
  • and [[Test Map Note]] specifies that the table should include all notes that have a wikilink to [[Test Map Note]]
  • and !outgoing([[Test Map Note]]) specifies that the table should NOT include notes that are currently linked within [[Test Map Note]]
  • and then I sort them by the date created, descending, so the newest notes are on top.

On the right you see the dataview table. Test Note 1, 2, and 3 all contain links to [[Test Map Note]], but only Test Note 3 is linked within [[Test Map Note]]. So inbox table only shows Test Note 1 and Test Note 2 (since these are the only notes linked to [[Test Map Note]] that are not linked within [[Test Map Note]]).

ADDENDUM on sub-maps:

Since I often refactor map notes so that instead of placing a note on the TOPMAP I place it on a SUBMAP that is itself linked to the TOPMAP. In that case, I want the inbox to only show notes that aren’t linked within either the TOPMAP or the SUBMAP (so that all the SUBMAP links don’t show up in my TOPMAP inbox).

To do that, we just need to add another line, before the SORT line, for each SUBMAP like so:
and !outgoing([[SUBMAP]])

I hope this trick can be helpful to yall!

Templater Snippet

And finally, here is the templater template I use to insert an inbox into a note:

table file.cday as "Date Created", file.tags as Tags
from "<% tp.file.folder() %>" 
and (#TAG1 or #TAG2)
and [[<% tp.file.title %>]] 
and !outgoing([[<% tp.file.title %>]]) 
sort file.cday desc

<% tp.file.folder() %> inserts the folder that the note is in (if the notes linked to the map note aren’t in the same folder as it, you need to set this manually.
<% tp.file.title %> inserts the title of the note that the template is inserted into.

8 Likes

An excellent contribution @pbhopeful . I have just added a version of this as a template that I am finding useful to drop into a few special MOCs :pray:

1 Like

@pbhopeful, thank you, this is very helpful! :pray:t2:

1 Like

Good call, Nick. I added my templater snippet to the post.

I like the idea of having inline-backlinks!

I tinkered a bit, and you can actually use a static dataviewjs script that does the same job, without the need for inserting the name of the current note via Templater. :slight_smile:

It uses dv.current().file.path to dynamically generate the current note’s path.

dv.span("**Backlinks to this Note**");
const thisNoteLink = "[[" + dv.current().file.path + "]]";
const outlinks = dv.pages("outgoing(" + thisNoteLink + ")");
const backlinks = dv.pages(thisNoteLink).filter 
	(link => !outlinks.file.path.includes (link.file.path));
dv.list(backlinks.file.link);

2 Likes

@pbhopeful

Just want to say thank you - thank you very much - for the method of …
<% tp.file.folder() %>!!

This approach is exactly what I was looking for and has let me set up beautiful templates.

(the DV javascript thing is far too complicated for me)
bw
A