Hi All,
What I’m trying to do
- I have folders: A1 and A2.
- I have templates: “Template B1” and “Template B2”.
For notes in folder A1, I would like to use “Template B1”, which has a tp.system.suggester prompt with simple “Yes”/“No” options. If “Yes” is selected, a new note “B2” will be created (using tp.file.create_new) in folder A2 using “Template B2”. If “No” is selected, “No” will be added to the note in folder A1 and a note in folder A2 will not be created.
Things I have tried
<% tp.system.suggester(["Yes", "No"], [tp.file.create_new(tp.file.find_tfile("Template B2"), "B2", false, "A2"), "No"]) %>
Using templater’s logic, this should:
- Display a Yes/No suggester menu
- If “Yes” is selected > create a new note > using “Template B2” > name the new note “B2” > don’t open the note (false) > create the note in folder “A2”
- If “No” is selected > add “No” to the current note.
Issues
When using the above, it mostly works as expected. A suggester menu pops up, I can choose “Yes” or “No”, and if I choose “No”, “No” is entered into the current note. However, I find that note “B2” is created using “Template B2” in folder “A2” (all correct) regardless of the yes/no selection made (incorrect). In fact, I can see in my file navigation side panel while the suggester menu pop-up is open that note “B2” is created before a selection is even made.
I’ve tried using “await” before and adding parentheses around the “tp.file.create_new” function, but nothing seems to prevent “B2” from being created, even if I select “No” in the suggester menu.
Another curious item, of less importance, is that selecting “Yes” in the suggester menu results not only in note “B2” being created correctly, but also in “[object Object]” being added to the original note in folder A1. I’d like that not to happen.
Here you can see that “B2” has been created, even before an option as been selected:
And here is the “[object Object]” in the note in folder A1 when “Yes” is selected.