Dynamic Suggester Template

What I’m trying to do

I want to create a solution to dynamically create template from a template based on Dynamic list of values shown in a suggester prompt UI.

for example i have Meeting Template, the template have two frontmatter variables
program:
Project:

Now i want to create two files in my vault

  1. Program
    the content of this file would be a list of all programs in any format that works eg.
    [program1, program2, …]
    or as a list
  • program1
  • program2

similarly another file for projects.

Then i want to have a QuickAdd action to trigger template, the template would show suggester UI prompt that load the list of program from the program file so i can select a program name from the list, and populate the fontmatter variable program in the file.

As i create new programs and/or projects, i will add its name to the file in my vault, the prompt suggester loads it in the UI when i create new meetings.

I’ve tried to use templater script + quickAdd but i wasn’t able to get it to work, any suggestions?

---
alias: 
project:
tags: meeting,
---
<%*
// load from some location
let projects = ['p1', 'p2','p3'];
let proj = await tp.system.suggester(projects, projects);
console.log(proj);

// How to set frontmatter project value? 

_%>
## Notes
- 

Thanks

Suggestion: move the Templater code block before the frontmatter section and use the variables to populate the YAML keys – project: <% proj %>. :wink:

Or you could add the following line to your Templater code block: this.project = proj;?

That’s an excellent question - would love to see a way to do this. For now, I accomplish something similar by putting all projects into its own file within a folder. The code below allows you to search all files within a folder, and then narrow down search via frontmatter. Hopefully it gives you some ideas…


<%*
const dv = this.app.plugins.plugins[“dataview”].api;
let allProjects = dv.pages(‘“020 Investments/Uninvested Funds”’);
let chosenProjects = allProjects.where(p => p.bucket == “LB”).file.sort(n => n.name);
let suggestions = chosenProjects.name;
let Entity = await tp.system.suggester(suggestions,suggestions)
let reason = await tp.system.prompt(“What’s reason for call/meet”)
let newTitle
let fileDate = tp.file.creation_date(“YYYY[-]MM[-]DD”)
if(tp.file.title.toLowerCase().includes(‘untitled’)) {
newTitle = ${fileDate} + " " + ${Entity} + " - " + ${reason}
await tp.file.rename(newTitle)
}
else newTitle = tp.file.title
await tp.file.move(“/010 Notes/” + ${newTitle})
_%>
Created: <% fileDate %>
Mode: <% await tp.system.suggester([“Call”, “Meet”, “Zoom”, “Meal”, “Letter”],[“Call”, “Meet”, “Zoom”, “Meal”, “Letter”]) %>
Entity: <% Entity %>
reason: <% reason %>
bucket: LB
Inv: N

<% Entity %> - <% reason %>