Find tasks which are scheduled in the parent block's page


I am not able to do a query for my needs.
Maybe somebody can help me which „phrases“ I am searching and if there is a solution somewhere already. :sweat_smile:

My structure is like this:

  • Daily Journal
    • Meetings
      • Meeting 1
      • Meeting 2

I add my notes below the meeting.
But how can I schedule a todo for the next meeting?
In other words: How can I automatically show open tasks in my daily - per meeting?

My approach: a template.
A template that I can add every day, per meeting (1, 2, …) which reads open/scheduled todos for the correct meeting (the parent block).

  • Daily Journal
    • Meetings
      • Meeting 1
        <—- add the dynamic template here
      • Meeting 2
        <—- add the same template here

So the question is:
**How to write a query (in a template) that finds all open tasks from a page. The page should be (dynamically selected) the page from the parent block **

I appreciate every help.

I had a similar need and it took me a while to figure this one out. My solution might be a little complicated but I’ll try to explain as I go. Probably someone can point out a simpler way. Here goes…

Let’s start at the end. I add a raise-with property to the tasks:

  • TODO Ask Person A about the thing
    raise-with:: [[Person A]]

Then in my meetings I link both the meeting and any attendees. Something like this:

  • 10:00 - [[Meeting X]] with [[Person A]]
    • Notes go here…

Notice that {{raise}} macro? That’s where the magic happens.

Inside config.edn I define the macro like this:


  :raise "\n#+BEGIN_QUERY
  {:inputs [:current-block]
    (pull ?block [*])
    :in $ ?meeting
    ;; The task or non-task block to raise is not 'done'
    [?block :block/page _]
    (not [?block :block/marker \"DONE\"])

    ;; The meeting refers to the page that the block has under its raise-with
    [?meeting :block/refs ?raise-with-page]
    [?raise-with-page :block/original-name ?raise-with-name]

    ;; The block has raise-with property that also refers to this page
    [?block :block/properties ?props]
    [(get ?props :raise-with) ?raise-with-set]
    [(contains? ?raise-with-set ?raise-with-name)]]

   :result-transform identity ;; Disable Logseq's own

   (fn [blocks]
     (for [b blocks]
       (let [label (first (clojure.string/split-lines
                           (:block/content b)))]
            (fn [_]
              (call-api \"open_in_right_sidebar\" (:block/uuid b)))}
           [:span.block-marker \"RAISE\"]


It’s a query that looks for the page reference in common between some block’s raise-with property and the references in the current block (the meeting header itself), then displays those blocks that satisfy this.

You could replace that whole :view ...} bit with :table-view? true} for a simpler setup.

Hey Ian

thanks for sharing this.
I have never worked with macros and will definitely give it a try to figure it out (even tho it does not work out of the box for me).

Thanks :grin: