What I’m trying to do
Hello !
I would like to create a task using Quickadd capture and the Tasks modal form via the API, and within the name of the task directly implement specifics tags (#Pro #Perso).
For which reason ? Because for each of those tags, I bind a custom hotkey to a QuickAdd command running with a dedicated capture format. And that’s where I got struggled, after roaming everywhere I don’t find a way to write the proper code to run that. Each time I have tried something either the tags appear before the checkbox making it deactivated either after the Tasks dates but unlikely disabling some dataview queries like “due next week”.
I wish I could have it like that:
- New task #Todo #Pro 2024-12-07
Things I have tried
Here is the code I pasted in QuickAdd into the capture format section, and trying to use the JS replace() method:
const tasksApi = this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1;
let taskLine = await tasksApi.createTaskLineModal();
const tags = "#Todo #Perso";
let result = taskLine.replace(`${taskLine}`, `${tags}${taskLine}`);
return result
If anyone has any suggestions, that would be very helpful. thanks !