Working with clients in Logseq: Dynamically access last reference date

Case

  • I’m working with clients and have separate page for each of them.
  • I use journal pages to make a reference to client page when we have a call.
  • I want to have a way to view the last call date without scrolling through all the client page.

Solution

Using 🏛 Full House Templates plugin:

2024-01-03 04.24.54

Setup guide is here.

Thanks. I must be stupid - I tried the last 2 hours trying to get this to work and I can’t figure it out. I went to your steps here:

and I’m stuck at the create view section - I’ve been copying and pasting the code into logseq but I don’t know how to get that code to run properly. Can I get a little more assistance? Sorry I’m new to logseq and plugins in general.

Detailed steps:

  1. You need to install the plugin
  2. Copy the 🏛️view code from GitHub via copy button
  3. Insert it to any block in Logseq
  4. Go to the edit mode of any block (but not inside the just copied view)
  5. Hit ⌘T (or Ctrl+T for Windows) — this is the default shortcut to call plugin insertion UI
  6. Type-in input name of the view or it’s part: «last»
  7. Select the appropriate item from the list — renderer macro will be inserted to current block
  8. Exit the edit mode (with Esc or Enter)
  9. Done

And, here is a demo of steps:
2024-01-03 09.39.31

1 Like

In case of any questions or difficulties — ping me

That workedI I think it was the way I was copying and pasting - when I used the github copy vs just selecting it didnt give me any errors.

The only problem I have left is it seems to be incompatible with the built in query function in logseq?
For example, I have on each client page a page property set as such:
last-contact:: {{renderer :template-view, last reference date, :reversed “”, :default “”}}

And then I have a separate page called “All Clients” that basically pulls in page properties from each client. But for the column “last-contact”, the entries are all blank in the query search despite on the page property it showing the proper date.
{{query (page-property :status “Prospective Client”)}}

Any way to fix this?

1 Like

Oh, yeah, it seems it is a Logseq bug. A fresh one.

While I dive into details, you could use a workaround. It’s a bit ugly, but will help to achieve the goal.

Steps:

  1. Transfer renderer macro code from property last-contact to any block in the same client page
  2. Copy that new block reference: ⌘C in block edit mode (or Ctrl+C for Win) OR via block context menu
  3. Insert an embedded block to last-contact property with /-command «Block embed»
  4. Paste copied block reference to embed macro
  5. Profit! — query table is working now

Demo:

2024-01-04 03.42.24

Yep that seems to work but very tedious/cumbersome. Is there any way to make the workaround smoother? Even something like having the renderer macro code in a separate block and then having the page property automatically reference the block right below or something? It’s really the manual step of getting each unique block reference code in every last-contact field that makes it painful and not very scalable across hundred+ clients

Is there a way you can also submit to the logseq github this bug so they fix it hopefully? I would do it myself but I dont quite understand the interaction between your plugin and how it causes this problem with the logseq query function (and they may put the blame on your plugin rather than the core app) so I think you may be able to provide better context or even submit a git pull request if you are familiar with their codebase.

My programming knowledge unfortunately is limited to basic python :slight_smile:

Have just created the bug. You can comment there to upvote it a bit.

About skipping manual step of getting block UUID:

  • If you are scripting creation of client pages, you can script and getting this UUID too.
  • Stable across graph re-indexing UUID is just a hidden property id:: of block.
  • So you can provide your own UUID string (created manually) and place it to block’s id property, and then use it in embedding.

PS: I don’t see another approach here. Only waiting for Logseq team to fix the bug.

1 Like

Sorry I dont follow. the UUID of the block will dynamically update or do I still have to manually enter in the UUID of the block each time for each client page?

  1. If you are using python script to create client pages, then you can generate embed block UUID within python too (because it is just a text property).
  2. If you have to create all client pages manually — then this step with embed block UUID is also manual.
    • I just got an idea: there is a chance to write the template which can help with this manual step. Need some time to figure it out.
1 Like

Oh no I’m not using python to generate the client pages, I just mentioned that as my very limited coding ability.

Great thanks a lot for the help - let me know if you are able find a slightly more elegant workaround. hopefully they can fix it soon although it looks like there are 1000+ issues outstanding still.

I’ll tip you some for your beer fund later :slight_smile: really appreciate the help.

1 Like

Done! We can write a special :classical_building:template to create client pages, which can emulate the creation of manual block:
2024-01-04 04.50.10

So, you only need to insert that special :classical_building:template to create a client page. But every client page need to be created manually. We cannot create 100+ pages at once with the :classical_building:template.

:classical_building:template:

- template:: new client
	- ```javascript
	  ``{
	    var content = '{{renderer :template-view, last reference date, :reversed "", :default ""}}'
	    var block = top.logseq.api.append_block_in_page(c.page.name, content)
	  }``
	  last-contact:: {{embed ((``block.uuid``))}}
	  ```
1 Like

I can’t seem to get this to work when I try to paste it in. Should I be removing the first dash when copying it into logseq? logseq keeps saying it does not support multiple unordered lists when I try to paste it in

EDIT: I kind of got it to work, when I delete all the other page properties I had in my template. I’m not sure why I am having issues if I have other page properties in, may be formatting.

If I wanted to use your template but include the following other page properties, what would be the proper formatting?

category::
status:: #[[Prospective Investor]]
process:: #active
referral::
last-contact::

Also one other possible bug - when I type /template, I get two options. One called Template which is the default template option in logseq and another called Insert Template or View which I think is your plugin. But when I do the option for your plugin, if I have multiple templates or want to select one, I can no longer select it using the down arrow key and I have to manually select it with my mouse cursor. Is this a bug too (albeit a minor one)? If I select the first “Template” option that is part of official logseq, I’m able to use arrow keys to navigate to whichever template I want to select.

  1. How to copy template code to Logseq?
    Just select it all and paste to Logseq. Nothing special:
    2024-01-06 20.49.54

  2. How to add new properties to the template?
    Just insert any text you want between last-contact:: and }}``

  3. Hot to insert template with the plugin (and not with the build-in template system)?
    There are three ways:

    1. Via default shortcut: ⌘T (Ctrl+T for Windows)
    2. Via /-command «Insert :classical_building:template or :classical_building:view»
    3. Via block context menu: right mouse click on root block with the template and select «Copy as :classical_building:template»
  4. Arrow keys do work. Just checked — it is worked for me on Mac and on Windows. Via /-command and via shortcut. I don’t know the reason it doesn’t work for you. Try to get out mouse pointer from opened window with templates list — this may help.
    2024-01-06 20.55.21

1 Like

strange - I can’t get the arrows keys working when I’m in “insert template or view” option even with the mouse pointer is outside of the template list (doesn’t make any difference). I’m using Mac OS version 0.10.3. Which one are you on? We may be on different versions - I dont get those arrow keys or inputs to popup like yours does either.

Also - is there any way to embed the block reference without creating a new block / bullet point? So instead of showing

last-contact:

  • 12-05-2023

it shows last-contact: 12-05-2023 (no bullet point)

  • It shouldn’t relates to Logseq’s version. I’am using the same one: v0.10.3.
  • The only things I can offer here is trying to restart Logseq or experimenting with other keyboards / machines. Does the issue still present in this cases? And ensure the input field is focused.
  • Oh! Yeah! The simple references also works!
    Relaces embed macro with simple block reference in template:

:classical_building:template

- template:: new client
	- ```javascript
	  ``{
	    var content = '{{renderer :template-view, last reference date, :reversed "", :default ""}}'
	    var block = top.logseq.api.append_block_in_page(c.page.name, content)
	  }``
	  last-contact:: ``[block.uuid]``
	  ```
1 Like

Thanks that code worked, and the restart fixed it (re: the keyboard input). Hopefully they can fix the bug soon so I don’t have to do this workaround!

Wonderful! We did it! :raised_hands:
If you still want to contribute to my beer fund, I’ll be greatly appreciated that :pray:

3 Likes

This is pretty amazing. The kind of detailed help you received here. Impressed.

2 Likes