Automatic Query based on the parent block reference

Hi All,

I have a meeting template (block) where i can add the name of the person i have meeting with or the name of the project (always page).
I would like to have a query automatic to retrieve all the block with the tag follow up.

I use this query, but it is not working, any idea?

thanks
Fede

Could you post the query as text so I can copy it?

Thanks for the help.
Here’s the code in text


#+BEGIN_QUERY
{ :title [:h4 "Follow-up Actions" ] 
:query [:find (pull ?b [*])
 :in $ ?parent
 :where
 [?parent :block/refs ?thing]
[?t1 block/name "🔍follow-up" ]
 (or-join [?b ?thing ?t1]
 (and [?b :block/refs ?thing] [?b block/refs ?t1])
 (and [?person :block/alias ?a]
 [?b :block/refs ?a] [?b block/refs ?t1]))
]
 :inputs [:parent-block]
 :table-view? false
:result-transform (fn [result]
                (sort-by (fn [d]
                           (get d :block/scheduled) ) result))
 :breadcrumb-show? false
:collapsed? false
}
#+END_QUERY

Not sure what the problem is? The query works just fine.
Please add some example where it doesn’t work.

image

Hi.
I think the problem is that the parent-block has different reference pages not only #chiccoach but also #meeting. The TODO that are created inside a meeting block also they have #meeting reference, so when I query I get all the TODO.
I will try to find an example.

My question is if the parent block has two references #meeting and #chiccoach, the query will search the block with reference #meeting AND #chiccoach or #meeting OR #chiccoach?

Thanks a lot for taking the time to help me out

In my graph the problem is that the query basically gives me all the TODO with follow up, not only the one with #chiccoach.
But if I try to do the same in a new graph seems working…so I am a little lost

Your query has 2 seperate conditions for returning blocks.
It returns either those blocks that reference follow up (?t1) AND whatever the parent block references (for example meeting OR chiccoach) (?thing).
OR
those blocks that reference follow up (t1) AND the alias of an (arbitrary) page (?a from not otherwise specified page ?person)

Maybe the problem is that you see blocks because of that second part?

Thanks!!
the mistake was in the variable ?person I forgot to change it to ?thing

:rofl: :rofl: :rofl: :rofl: :rofl:

1 Like