Advanced Query - trying to query all tasks referring to pages with two particular page properties

Hi everyone,

I’m a complete novice in programming, but am trying to get something to work and really struggling.

Hopefully this explanation makes sense:

I have a separate page for each project.

Each active project has a page property type:: #matter and status:: #active.

I create tasks for these projects on both the project page and/or in a journal page.

On a new page called (e.g) “Active matter tasks” I want a query which returns all “TODO” and “DOING” tasks which have the name of an active matter page in them (regardless of where the tasks appears).
I am particularly struggling to work out the correct coding to interrogate the page properties of the page referred to in the task.

I’ll just set out an example of the pages and then include the draft query which I’m hoping someone can help me with.

Basic pages concept:

-Journal page-
TODO [[Project 1]] return important email
DOING [[Project 2]] work on presentation

-Project 1 page-
type:: #matter
status:: #active

TODO [[Project 1]] prepare for meeting

-Project 2 page-
type:: #matter
status:: #active

TODO [[Project 2]] return telephone call

-Active Matter Tasks page -
Query showing all TODO and DOING active matter tasks (i.e. all the tasks above)

My not-working code:

#+BEGIN_QUERY								; attempted query for tasks which include a reference to a page with specified page properties
{:title "I'm stuck"
:query [:find (pull ?b [*])
    :where 
	(task ?b #{"TODO" "DOING"})				; I think I have this part right (hopefully)
   											; now comes the bit where I get lost
    [?b :block/refs ?ref]        ; unsure if this is the correct starting point? 
    (page-property ?ref :status ?status)  ; whatever else is wrong with this line and the next, they only look at one of two properties and ideally I would like to only return tasks that have both #active for the property "status" and "matter" for the property "type" - not sure best way to phrase that argument here
    [(= ?status "active")]
	
    ]
 											
}
#+END_QUERY
1 Like
  • Should be (page-property ?ref :status "active")
  • Then combined like this:
    (and
        (page-property ?ref :status "active")
        (page-property ?ref :type "matter")
    )
    
2 Likes