Assigning roles to an organization

Hello All… I’d like some tips on how to setup this scenario. I work with lots of Scout units, and I’d like to build a page for each Unit and a page for each Person. My thought is to have an area under each person with the units they work with, so like this on say the Contact page for “Jane Jones”:
Current Unit Roles

  • [[Troop 1234]]
    • Assistant Scoutmaster
  • [[Pack 1234]]
    • Cubmaster

Then on each Unit page have a query to pull in all roles for the unit in a grid with the name, position, plus maybe some basic info like email or phone. Any tips on how to do this? I’m quite new to Logseq so everything I’ve tried has not worked. Thanks for any tips or ideas on how to do this.

What you ask is not impossible, but not easy either. However, before messing with a working query, should probably reconsider the proper structure of your notes. Here are two alternatives to what you describe, that may simplify some things:

  • Use properties in the page of each unit.
    • e.g. line cubmaster:: [[Jane Jones]] in the beginning of page Pack 1234
    • This approach:
      • may be more convenient when reading data
        • Especially when hovering on a unit to get a quick view of it.
          • Likewise, it is probably better to read the email/phone by hovering instead of from the grid.
      • may need an easier query on each person’s page
        • Unless the Linked References are already enough.
  • Express the roles as natural notes inside the journal
    • e.g. [[Jane Jones]] is [[cubmaster]] in [[Pack 1234]]
    • This approach:
      • may be more convenient when entering data
        • to do almost everything from within the journal
      • may need a type:: property in each page
        • to differentiate your entities (person, role, unit etc.)

Agree with a lot said there.
I was able to make something work for that specific layout but … it may be flaky or pick up extra references as the current setup is quite ‘loose’ with constraints to query against.
Currently requires a page with phone and email properties.
Given a person page like so:
something like below query could work (example pic)

{:title [:h3 "Positions"]
:inputs [:query-page]
:query [
:find (pull ?b [*]) ?p ?email ?phone
:in $ ?unit
:keys role page email phone
    [?p :block/name ?unit]          ; page ref for 'unit' page
    [?par :block/path-refs ?p]      ; block parent references unit
    [?b :block/parent ?par]         ; get block parent
    [?b :block/page ?pg]            ; get block page
    [?pg :block/properties ?props]  ; page properties
    [(get ?props :email) ?email]    ; page must have email property
    [(get ?props :phone) ?phone]    ; page must have phone property
:result-transform (fn [result]      ; alter result to attach additional properties to block
          (for [row (sort-by :date result)] 
           (let [block-map (get row :role)
            current-properties (:block/properties block-map)
            block-page (:block/page block-map)
            person (:block/original-name block-page)
            updated-properties (assoc current-properties   ; attach extra properties to block
              :person person
              :email (:email row)
              :phone (:phone row)
            (assoc block-map :block/properties updated-properties)
           ) ;end let
          ) ;end for
          ) ;end fn
      :view (fn [rows] [:table 
          [:thead [:tr 
          [:th "🚩Role"]
          [:th "👤Person"]
          [:th "✉️Email"] 
          [:th "☎️Phone"] 
          ]] [:tbody (for [r rows] [:tr
                (get-in r [:block/content])
            [:td [:a ; link to person
                {:href (str "#/page/" (get-in (get-in r [:block/properties]) [:person]) )} 
                (get-in (get-in r [:block/properties]) [:person]) 
             [:td [:a ; mailto allows emailing for devices that support it
                {:href (str "mailto://" (get-in (get-in r [:block/properties]) [:email]))} 
                (get-in (get-in r [:block/properties]) [:email]) 
            [:td [:a ; tel protocol allows calling on devices that support it
                {:href (str "tel:" (get-in (get-in r [:block/properties]) [:phone]) )} 
                (get-in (get-in r [:block/properties]) [:phone]) 
1 Like