Smooth creation of notes with templater+buttons and ICloud on Windows

Hello,

I am a fresh obsidian + templater user and I want to thank everyone on this forum for sharing very valuable info.
I would not have been able to progress without your insights, so many thanks!

I created this account in an attempt to share something back, if possible.
I am gradually transferring pretty much all of my data to obsidian, among which I can mention:

  • daily schedule
  • projects and tasks
  • financial planning / monthly budget
  • food planning
    etc.

What is amazing about obsidian is the fact that it also works on mobile. This is particularly important for me because I tend to do many updates on my phone, for example logging expenses straight in the shop, or recording ideas immediately as they appear.
In order to get better mobile experience I use the buttons plugin, which makes adding content a breeze. My vault sits in the ICloud on Windows. Now here is where the problem appears.

  1. I have a button from Buttons plugin by Sam Morrison which can create new note from a templater
  2. I create new note from, lets say, “Project Template”
  3. The “Project template” may look something like this:
---
<%* 
title = await tp.system.prompt("Project Title") ?? "New Project";
await tp.file.move(`Projects/${title}`);
-%>
datetime: <% tp.date.now("YYYY-MM-DD ddd HH:mm:ss") %>
type: project
---

# <% `${title}` %>
  1. The new note is created in default folder and the template is resolved
  2. PROBLEM: While it should work fine, the ICloud prevents from moving the file and shows a prompt window in the background (you have to look for it) in roder to complete whole operation.
    This is not ideal, since the templater may have a timeout and not resolve template at all leaving some random Untitled note and creating a mess.

I stepped upon the solution to this, which seems to workm flawlessly for me both on desktop and mobile. Here is how it works:
Create two templates - one for the file prompt and one inside the file just for moving to right directory.

  1. Use button plugin to append a template:
<%* 
title = await tp.system.prompt("Project Title") ?? "New Project";
await tp.file.create_new(tp.file.find_tfile("Project Template"), `${title}`, true)
-%>
  1. Notice the “Project Template” that is used to create new note. Here is how it looks like:
---
<%* 
title = tp.file.title;
await tp.file.move(`Projects/${title}`);
-%>
datetime: <% tp.date.now("YYYY-MM-DD ddd HH:mm:ss") %>
type: project
---

# <% `${title}` %>

This works flawlessly. I still get prompt window to specify the project file name, and then the project is created and prefilled with information based on it’s file name.
The file name is determined before creating the note; The first template is removed due to the ‘-%>’ closing syntax and the project file is moved without the ICloud interfering.

I know you you can create the note straight from a template, but this one focuses on using buttons.
I hope it helps anyone who came across similar struggles. If not, please feel free to delete this post to oblivion.

edit: inconsistencies

1 Like