How i can do this: "Extract task list in a file, but when i mark task as completed this they must not be changed in the source file"?

I have a file that contains a list of tasks, I have tasks that I want to execute once and tasks that are recurring.

I want to extract these tasks in the file created using the Daily Note plugin, if I extract these tasks using the dataview plugin and mark a task as completed this task will be completed in the original file as well, but I don’t want this to happen for the tasks as well of recurring notes, because then I have to deselect them every time in the original file.

I have my query that extract the task that i want :

TASK FROM "Produttività 🎯/To-Do List 📝"
where (containsword(text,[0]) or containsword(text, "sempre")) and priorità = "alta"

I need only the method for don’t mark as checked (in original file) the task that i mark as checked in my current file.

For example:

If in my current file i mark a task as completed (task extracted using the query):

In the original file (the file that contain the task list) i don’t want this:

Direct answer: with dataview you can’t!

Let’s see things in this way: dataview results are a dynamic results, i.e., they’re produced when you render the code. So, each time you render the page you see the dynamic results (there’s cache, but isn’t important to explain this point).

We can build a query only with the text of the tasks and add a “fake” checkbox. But then what? It’s a visual thing, there’s no memory to record what we have done in the render view!

Next time you (re)render the page, it will execute again the same code… and in the raw content there’s no “x” inside the checkbox!

  • query to test purposes (a fake task list) :
	"- [ ] " + T.text
FROM "Produttività 🎯/To-Do List 📝"
WHERE file.tasks
FLATTEN file.tasks as T
WHERE (containsword(T.text,[0]) OR containsword(T.text, "sempre")) AND priorità = "alta"

Returning to the dv task query. Tasks queries are, by obvious reasons, the only cases that have the ability to “write” in the file, i.e., a interaction between the render and the raw content.

1 Like

Your only solution is the conversion of the dataview results to a static thing… as you asked in another post. But that requires some complex dataviewjs and templater (accessing dataview via API)… ma è possibile.

1 Like

Ok, so i have to search another method :thinking: , i think in this case the only solution i have is to creata a program (maybe in python) that automatically search the task and write they in my file o something similar.

Are you interested to explore the conversion from dataview results to static results?
If yes, we can built a way. (the only thing I think you need to change in your query is the replace of “[0]” by the real number)

Better if I leave here one example:

  1. Create a templater file with this content (as is):
//the dv query
const query = `TASK
FROM "Produttività 🎯/To-Do List 📝"
WHERE (containsword(text, "3") OR containsword(text, "sempre")) AND priorità = "alta"`

// get the results from the query above
let DQL = await DataviewAPI.tryQuery(query);

//the task list
const myTasks = DataviewAPI.markdownTaskList(DQL.values)
<% myTasks %>
  1. return to your note and run/insert the created templater
1 Like

I solved my problem by getting my hands a little dirty, solution is here: Query that write result on current note? - #4 by Giovanni27072

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