Get Tasks linked to this note

What I’m trying to do

For a given note, I want to get all tasks that link to this file.

Things I have tried

TASK
FROM ""
FLATTEN file.tasks AS Tasks  
WHERE contains(Tasks.outlinks, this.file.link)

This is returning ALL tasks from files that link to a given note. This is not returning JUST the tasks linking to a given note.

Thanks!

Do you mean TASK FROM [[]] ? Or TASK FROM outgoing([[]]) ?

I believe TASK FROM [[]]

To clarify, let’s say I have the following files: Boss.md, Peer1.md, Subordinate.md, Project1.md, Meeting1.md, DailyNote#.md

Now imagine that during Meeting1, I write something like:

- [ ] Coordinate with [[Boss]] and [[Peer1]] whether [[Subordinate]] should work on [[Project1]].

I would like to embed/show this task across all surfaces affected. Meaning that I would like to see this task show up on Boss, Peer1, Subordinate, and Project1.

The current snippet shows these tasks but it also shows more tasks than necessary. For example, let’s imagine on Daily#.md I have:

- [ ] Talk to [[Boss]] about resourcing
- [ ] Do grocery shopping

My current script would embed these two tasks in Boss.md

I use this to do what are asking:

```dataview
TASK
WHERE (contains(outlinks, [[]])
    OR contains(path, this.file.name) )
    AND status = " "
```

It grabs all tasks that link to the current file, OR tasks that are in the current file (as long as the task is not done. I put this at the top of files for specific people or projects and use it as a way of getting all related tasks in one place (I often put tasks for a specific project in that file as well in other notes, hence the OR clause. If you don’t do that or want, just remove that line and the first bracket after the WHERE).

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.