How can I take a static snapshot of a note that has dynamic content?

What I’m trying to do

I have daily notes that rely on dynamic content through Dataview and Tasks queries.

When I look back at my notes some time after, these dynamic queries don’t return the same results. For example, tasks that have been done since no longer appear in the todo section. So the note no longer reflects what that day was made of for me.

I would like a feature – but perhaps it’s already doable, hence the help topic – that would fixate the output of the queries by converting them from dataview or tasks to actual markdown.

This is somehow related to the plugin idea post I submitted a few days ago, about a way to annotate the output of queries. Both requests could be merged into one. A sort of a note-compiler.

Things I have tried

The only thing I could think of was just to adapt some parts of my code so that, for example, it doesn’t fetch tasks that are “not done” but those that were not done <= note’s creation date. This can work for tasks. But I have, for example, a section of my daily note that returns ongoing projects, by searching notes with “type: project” and “status: ongoing”. A few days later, if the same project is over, the output of the query will change, so when I look back on this note I won’t be able to say “oh, this project was still ongoing back then”.

Replying because I’m really interested in this as well, for much the same reasons/use cases. For a while I resorted to manual screenshots of the relevant part of the daily note, taken and attached in place of the dataview queries, done manually at the end of the day (icky, but it worked). Something automated and searchable ie. Text would be ideal.

As a workaround, I was thinking maybe a shortcut (or other automation) in the spirit of this one, except that it’s not working? I don’t really know how to retrieve the content of the open note, the “retrieve screen content” action I’m using here doesn’t seem to work. But basically: Select all, Copy, Paste in a new document, Save as md file in a snapshots directory.

(I’m launching this shortcut from the daily note I want to capture, with the note’s title as a shortcut input)

And now that I think a bit about this, could a templater script do this? Run the same dataview queries, but insert the results as text rather than straight into the page? (Doing this is probably past my reasonably limited templater and dataview skills)

1 Like

Yes, there has to be an in-app solution… alas, it surpasses my skills as well. :confused:

Ok, the general approach is definitely feasible, outlined here:"Burning out" dataviews · Issue #42 · blacksmithgu/obsidian-dataview · GitHub (and throughout that thread).

Triggering it in the right time/place, I don’t know. Unless you manually removed the “live” query block and run that templater script at the end of every day, in every project or journal note that needs it :neutral_face:

Not exactly a snapshot and I don’t use the Tasks plugin, but I used to use Templater and Dataview to keep created and modified files in a daily note callout. Because the queries are tied to mday and cday, they (mostly) return the correct notes created or modified on that day when looking back through my old daily notes.

> [!tip]- Today's Notes
> ```dataview
> list
> file.cday
> where file.cday = date(<"YYYY-MM-DD")%>)
> sort file.cday ASCENDING
> ```

> [!example]- Modified Today 
> ```dataview
> list
> file.mday
> where file.mday = date(<"YYYY-MM-DD")%>)
> sort file.mday ASCENDING
> ```

I wonder if you could use cday or mday for task items?

Edit: this plugin (Copy-as-html) seems more appropriate for my use case, as it allows to render an HTML copy of a note (which could then be saved in a snapshots directory). Still not exactly the markdown note-burner I’m looking for, but I’m moving the Solved tag to this post for that reason.

I used to use Templater and Dataview to keep created and modified files in a daily note callout

Yes, I do this too in my weekly note (notes that were created on each day of the week). It works fine but unless we opt for a whole different strategy for tasks where each task is a note, like I’ve seen some people do, I don’t think it could be done for tasks and it also doesn’t solve the problem of queries that return notes with a given metadata value at a specific time.

Thank you for finding this GitHub thread @ShaneNZ. It looks like the feature should be in the pipes for Datacore, as per this post by the dev, which exactly addresses my question (except that Obsidian Tasks queries will require some adaptation):

I have two modes which I am planning on supporting directly right away:

  • Preview mode: All dataviews will support both “Export to Markdown” and “Freeze as Markdown”, which (1) copy markdown for you to paste, and (2) directly replace the query block with markdown. This requires manual action to freeze but at least enables the core functionality.
  • Bulk Freezing: Dataview will provide a simple UI for replacing ALL queries in your vault with their static results in one atomic operation - best for if you are migrating away from Obsidian or Dataview but want to keep all of your tables and indices. This will also support the ability to keep the existing Dataview block and just append the result as Markdown after the block.
    These two scenarios should unblock the most important use-cases: data archiving, basic view support in publish and GitHub, migrating away from Dataview, and even being able to see important Dataview-based links in the graph. I can also consider implementing “Bulk Freezing” as a simple automatic job that runs at user-defined intervals or on important operations.

And the workaround strategy indeed involves Templater as per this post by some angry person:

write a templater script to then output the table into another file where I then copy paste the source to post it somewhere else

(+ Buttons / Commander ?)

I’m marking this topic as solved as the question can be considered as answered, though I’ll probably wait for that update before I move on this. Thanks!

There shouldn’t be any reason why you can’t use Templater to trigger a DataviewJS task query, and insert the static version of that query using the dv.markdownTaskList() function.

You’re right, that should be doable. It’s just that I prefer to query tasks through the Tasks plugin, I find the way tasks are displayed more convenient. So I use dvjs task queries to evaluate the number of potential results, and if it’s >0 I use dv.paragraph to call a Tasks query with exactly the same terms.
In the case of the projects list I suppose you’re right.

EDIT: It works indeed. In case somebody else is searching, this is how I replaced my former Dataview query:

	const dv = app.plugins.plugins["dataview"].api;
	const query = `TABLE WITHOUT ID link(, banner_icon + " " + project) AS Projet, row["Prochaine action"] as "Prochaine action" WHERE type="dashboard" AND status="en cours"`
	let out = await dv.queryMarkdown(query)
	tR += out.value

Now it would be perfect if there was a way to query the Tasks API the same way, but I only see a method to call the task creation modal.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.