Dynamicly modify all project-dataviews in one step

Hi guys,

in my daily work I log every call, meeting, … in a obsidian-project-note. The note is parted in two sections:

  • Section 1: dataview of all logged Milestones and todos in that project
  • Section 2: protocol / log of all calls, meetings, …

see screenshot as an example:

My Code I use for that is:
for Milestones-dataview:

	Tasks.from AS "from   ", 
	Tasks.to AS "to              ", 
	regexreplace(Tasks.text, "\[.*$", "") AS Milestone, 
	Tasks.link AS "date milestone created"
WHERE file.tasks FLATTEN file.tasks AS Tasks 
WHERE contains(Tasks.text, "#ms")
WHERE !Tasks.completed 
WHERE file.name = this.file.name
SORT Tasks.to DESC

for Todos-dataview:

	Tasks.to AS "To             ",
	regexreplace(Tasks.text, "\[.*$", "") AS Todos, 
	Tasks.fb AS "Feedback @",
	Tasks.link AS "link" 
WHERE file.tasks FLATTEN file.tasks AS Tasks
WHERE contains(Tasks.text, "#todo")
WHERE !Tasks.completed
WHERE file.name = this.file.name
SORT Tasks.due ASC

Now, as I’m learning, how to use dataview correctly, I don’t want to modify/adjust all my 20 project notes, after for example @scholarInTraining has helped me out again und explained, how I should modify my code, to get the desired result.

My Idea is:

  • Is there a possibility to save these two dataviews as kind of a “project-header” which could be embedded at the beginning of every project-note?
  • And if I change/modify/correct that header-file, alle the dataviews in my 20 project-notes are updated automatically?

Thanks a lot in advance!

1 Like

This is a great question! I know this can be done in dataviewjs, by putting the dataviewjs in a separate .js file (which has to be edited outside Obsidian) and then using dv.view(...) to call to that file from the header you have described. (You can then put the header in your template note for the project, since you’ll always be calling to the same file even if you change the .js file contents. I am not sure about regular dataview. I think @Craig was the one I initially learned about dv.view from, and perhaps will have other ideas here?

It sounds like you want to craft a DQL query that refers to the current page, and then embed it in multiple project pages. Unfortunately this isn’t possible as far as I know, because when embedding the query, this will refer to the embedded page, not the embedding page.

I don’t know of any way to create such a DQL query without creating a copy of it on every page. I think it would require some new keyword in Dataview similar to this, that refers instead to the outermost page – if that’s even possible.

On the other hand, as @scholarInTraining points out, you can do this in DataviewJS. First, you would need to rewrite your queries as standalone JavaScript files, then you can use dv.view() to import them and execute them in the context of the current page. It’s not trivial, and requires some knowledge of JavaScript, but it can be done.

Thank you very much for your advice! As I do not know JavaScript, that won’t be an alterantive for me in the next future. But anyways: Thank you so far!

1 Like

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