Adding internal links via js code

Hi,

I am currently in the process of setting up a task management system for project management. For this, I want to semi-automate the process of adding a task in meeting situations, like this:

  • For each project, I have a Kanban file, which contains the individual tasks of the project.
  • Each project has a specific and unique tag
  • while I am in a project meeting, I am writing my meeting notes in a separate meeting note (not in the project Kanban file!), including new tasks for the project
  • these tasks are being automatically added to the corresponding Kanban file under the ##backlog section based on the tag assigned to each task, e.g.
    • Project A, tag #project/Project A
    • task: Task 1 – Project A, [due:: 2023-08-10], [priority:: high], [owner:: Steve], #project/Project A
    • Kanban File: KB_Project_A, section ## backlog, Task 1 being added automatically in the background while I am still in the meeting notes writing.

This all works fin, but …

What I’m trying to do

… I want to see the task also in the meeting note which I am writing at that moment as an internal link reference to the Kanban file, :wink:
Like this:

meeting note:
![[KB - Ambition-Lab-Austria#^7580dd]]
image

Things I have tried

So I have added to the task-description at the very end a section marker to identify an internal link with a random three-digit number like this: ^block_link123. Then I am trying to via the js code to add this link to the current document.

I have a variable defined, which contains the task I am adding to the Kanban Board:

const stringToAdd = `- [ ] ${var_taskname}, [priority: ${taskPriority}], [owner: ${var_owner}], [due: ${var_due_date}], ${var_choice[0]}, ^block_link${randomNumber} `;

This contains various other var’s which I defined while adding the task to the Kanban board.
And it also contains the block_link reference with the 3-digit number randomNumber: `^block_link${randomNumber}``

I am now defining a new variable referLink:

const referLink = `![[${var_KB_board}^block_link${randomNumber}]]`; 

This contains the project Kanban Board where I have added the task and the section, which identifies the specific task.

The var referLink I am adding to the current document – the meeting note:

 await tp.file.cursor_append(referLink)

It is added to the meeting note, however, without an active reference:

The reason is: Obsidian apparently adds to every internal link their link reference, once the link is being initiated:
image
The 7580dd at the end is the actual internal link.

So what I need to do, is to write a js code, which acts as if the link is being actually initiated the moment I add it to the Kanban board and then reference it in the meeting note.

I know this sounds very complicated – and it is. But for clarity reasons, I would rather not add the whole code here, which is like 170 lines.

Happy to provide more details, if somebody is willing to look into this :wink:

Thanks a lot for helping!

For anybody, who might be interested in the solution - after using some AI in analyzing the code, the AI pointed me to the solution:

I made a mistake in a part of the definition of the referLink as I was missing the # in the variable.

If the referLink is defined as follows:

const referLink = `[[${var_KB_board_int_link}#^blocklink${randomNumber}]]\n;

it works :wink:

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