Help with automation for obsidian life OS vault

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I am trying to link my task template with my project template work flow. I have a button using metabind plugin on my project template that creates a task template. I am trying to auto link the task to the project from one click of the button. Is it possible to on the button press to add to the frontmatter to a template note. I have in my task template frontmatter field called related notes.

Plugins installed
Dataview
Templater
Commandar
Metabind
metadata menu
remotely save
hompage
journals
linter

First attempt:

label: Create Task
icon: ""
hidden: false
class: menuButton
tooltip: Create a task for the project
id: taskButton
style: default
actions:
  - type: templaterCreateNote
    templateFile: "Task Template.md"
    folderPath: "6. Task ✅"
    fileName: ""
    openNote: true
    openIfAlreadyExists: false
  - type: appendFrontmatter
    file: 6. Task ✅/<% tp.new_file_name %>.md
    key: Relate_Project
    value: [[<% tp.file.title %>]]
  - type: appendFrontmatter
    file: <% tp.file.title %>.md
    key: Task
    value: [[6. Task ✅/<% tp.new_file_name %>.md]]

#### Second Attempt
```meta-bind-button
label: Create Task
icon: ""
hidden: false
class: menuButton
tooltip: Create a task for the project
id: taskButton
style: default
actions:
  - type: templaterCreateNote
    templateFile: "Task Template.md"
    folderPath: "6. Task ✅"
    fileName: ""
    openNote: true
    openIfAlreadyExists: false
  - type: appendFrontmatter
    file: 6. Task ✅/<% tp.new_file_name %>.md
    key: Relate_Project
    value: [[<% tp.file.title %>]]
  - type: appendFrontmatter
    file: <% tp.file.title %>.md
    key: Task
    value: [[6. Task ✅/<% tp.new_file_name %>.md]]
  - type: removeFrontmatter
    file: 6. Task ✅/<% tp.new_file_name %>.md
    key: tags
    value: "template"
  - type: removeFrontmatter
    file: 6. Task ✅/<% tp.new_file_name %>.md
    key: tags
    value: "default"


#### Third Attempt
##### JS File
module.exports = async (tp) => {
  const frontmatter = tp.frontmatter;
  if (frontmatter && frontmatter.tags) {
    const tags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [frontmatter.tags];
    const filteredTags = tags.filter(tag => tag !== 'template' && tag !== 'default');
    await tp.file.writeFrontmatter({ ...frontmatter, tags: filteredTags });
  }
};

##### Markdown files
```meta-bind-button
label: Create Task
tooltip: Create a task for this project
id: create-task-button
style: default
actions:
  - type: templater-create-note
    template: "Task Template.md"
    folder: "6. Task ✅"
    open: true
    name: ""
  - type: command
    command: templater:run-user-script
    args:
      script_name: "remove_tags.js"
      file: "{{last-created-file}}"


<!-- Below this line, describe what you're trying to accomplish so the community can help you find the best solution. -->


### Things I have tried
I have used chatgpt as I am still struggling to really understand how obsidian uses JavaScript. I have read the documentation for meta-bind.

<!-- Below this line, write what terms you searched in the help docs and forum, plus any solutions you tried and what happened. -->