Trigger Command: Replace templates in active file

I create a Daily note and its template has several Template statements that execute user scripts at the beginning that generate properties, title, navigation, and calendar content.

<% tp.user.dayNoteProperties(tp) %>

<% tp.user.dayNoteTitle(tp) %>

<% tp.user.dayNoteNavigation(tp) %>
<% tp.user.dayNoteCalendar(tp) %>

However, those scripts are not executed when AFO creates the Daily Note using that template. I can manually use the Templater command to “Replace templates in active file” and that works. I’m not sure why they aren’t run during note creation from the template.

So I thought maybe I could use a Trigger Command action after Create Daily Note to automatically replace those template statements that I can do manually. But that does not work as I expected it would. I load the Command List at the beginning of the shortcut.

These used to work before changing to the Create Note rather than Create Periodic Note. What am I missing?

Are you running Actions URI 1.7.2 yet? Because it (supposedly) contained a fix/workaround for exactly that issue: Release: Actions URI 1.7.2

Yes, Actions URI 1.7.2 on Obsidian 1.8.9.

Good. Okay, hmm. On Mac, yes?

However, those scripts are not executed when AFO creates the Daily Note using that template. I can manually use the Templater command to “Replace templates in active file” and that works. I’m not sure why they aren’t run during note creation from the template.

Neither am I, but I suspect it’s another race condition of sorts.

So I thought maybe I could use a Trigger Command action after Create Daily Note to automatically replace those template statements that I can do manually. But that does not work as I expected it would. I load the Command List at the beginning of the shortcut.

Could you please provide a screenshot of the relevant portions of the workflow, or maybe the workflow itself (DM or email would be fine).

Yes, this occurred on macOS.

If it’s a race condition right after creating a daily note, would it help to move the Trigger Command further down in the workflow to get it some time to settle down.

Here’s the relevant section of the shortcut workflow.

Thanks. I added the placeholders to a daily note template and let Periodic Note create it, and Templater complained about the tp.user.* functions not being functions (in the console), and never got to replacing anything.

Templater Error: Template parsing error, aborting. 
tp.user.dayNoteProperties is not a function

Templater Error: Template parsing error, aborting. 
tp.user.dayNoteTitle is not a function

etc. But that happened even outside of AFO’s “jurisdiction”, i.e. even when I called Periodic Note’s “Open daily note” command via the palette.

As for the screenshot (thanks!), let’s see…

  1. Unless your available commands change hourly or daily, there’s no need to call Get Available Commands every time as part of that workflow (see notes on its documentation page).
  2. Create Note returns a Note, and supports opening/focussing the new note, so I think the extra Get Note is superfluous.
  3. If the tp.user.* calls I mentioned above work fine in your vault, then maybe a short pause between note creation and Trigger Command might help? Just a thought…

My mind is a bit mush at the moment (busy days…), so apologies if I did ask this already in another thread – how does your Daily/Weekly notes setup look in general? Daily Notes core plugin, Periodic Notes community plugin, anything else?

Those are Templater user scripts so they need to exist and be loaded in Templater settings in order to be recognized. They’re not built into Templater, but JavaScript functions that I created. They generate the properties, title, navigation, and calendar for the Daily note.

I use the Periodic Notes plugin with Templater, not the core Daily Notes plugin,

I will try inserting a pause after Create Note before Trigger Command to see if that helps with the timing. I was a little confused since Trigger Command applies to “the active note”, and I wasn’t sure if the newly-created Daily Note would be “active” if I didn’t use the Open/Focus option, and therefore added a Get Note to make it “active”. Also, I might move it later in the workflow after some other actions so some time will have passed after creating the daily note; although, then I might need to use the Get Note so it’s active at that time.

I guess I was thinking that you needed to use Get Available Commands at the beginning of a shortcut before using Trigger Command. I will have to read the documentation more closely.

Thanks for the suggestions about extra actions that aren’t really needed in my workflow.

Those are Templater user scripts so they need to exist and be loaded in Templater settings in order to be recognized. They’re not built into Templater, but JavaScript functions that I created. They generate the properties, title, navigation, and calendar for the Daily note.

I suspected it but didn’t look it up, so thank you for the explanation!

However, those scripts are not executed when AFO creates the Daily Note using that template. I can manually use the Templater command to “Replace templates in active file” and that works. I’m not sure why they aren’t run during note creation from the template.

Let’s compare notes to ensure we’re doing the same things.

I set up a folder template in Templater so it’ll auto-apply the Daily Note template (_templates/Daily note.md) to any new empty note in Daily Notes/:

Then I added a bunch of standard Templater placeholders to the Daily Note template (_templates/Daily note.md):

<% tp.file.creation_date() %>
<% tp.date.now("YYYY-MM-DD", -1) %>
<% tp.date.now("YYYY-MM-DD", 1) %>
<% tp.file.title %>

Finally, I set up Periodic Note to just create an empty note in the Daily Notes/ folder.

Both “Periodic Notes: Open daily note” via command palette and Create Note via workflow do work:

Does anything I did here jump out at you? Also, does the developer console (Main menu → View → Toggle Developer Tools) show any errors when you run the workflow?

I don’t use Folder Templates, so I just created a Day Test template, updated Periodic Notes (Daily) to use that, and then use a Shortcut with Create Daily Note. It successfully created a new daily note, but the templates were not processed; they still exist exactly like in the template.

Here’s my Day Test template:

This is my Create Day Test shortcut:

After creating the Daily Notes with the Shortcut action, this is the new daily note:

Here’s is the console log:

I originally didn’t know why I got this same error message before both the AFO URL action and Actions URI Called handled:

ForceViewMode: Folder Name does not exist or is not a folder.

After some investigation, I discovered it was coming from the Force Note View Mode plugin. Apparently, I had it still set to use Preview mode for all notes in a Home folder; however, that folder no longer exists, and my Home note is now in the root folder. So I turned off that plugin since I have the Homepage plugin configured to open my Home note in Preview mode anyway.

When I use the Command palette to Templater: Replace templates in the active file, it processes those templater statements producing the following expanded daily note:

So this demonstrates that Templater statements are NOT being processed when using AFO Create Daily Note with its template. I hope this helps provide some additional information to see what’s happening here.

Thank you for the write-up! :pray:t3: That’ll give me plenty to work with. I’ll get back to you soon, hopefully with some definitive answers :wink:

Okay, I’ve looked into it, and I can’t reproduce it, I’m afraid. :worried: To recap, here’s what’s happening when AFO calls Actions URI with the task of creating a new daily note, in sequence:

  1. Actions URI triggers note creation by calling an API function of obsidian-daily-notes-interface library,[1] which (internally) creates the note after replacing Periodic Note’s own template tags.
    → This seems to work a-okay.

  2. Entirely independent of Actions URI, Templater observes note creation, and replaces its placeholders in the newly created note.
    → This doesn’t seem to work.

Actions URI can’t and is not supposed to call Templater because Templater has its own observation loop and everything. Neither is Periodic Notes, for that matter, for the same reason.

It’s all a bit weird, I’m afraid. If it were my vault, I’d disable all plugins except Actions URI, Periodic Notes, and Templater, and re-run the test setup from AFO a few times. If it works, the issue is likely with one of the disabled plugins.

Sorry, I wish I could tell you anything else.


  1. That’s the obsidian-daily-notes-interface library Actions URI uses which deals with both Periodic Notes and Daily Note; it’s written by the same person who wrote Periodic Notes, i.e. Obsidian dev team member Liam Cain, as a dev-focussed counterpart to the Periodic Notes and Daily Note plugins. And I’ve checked their implementation – the new note is created using the standard Obsidian API call, nothing fancy. ↩︎

Thanks for investigating the problem. Do you think it would be any different if I used Create file at path and explicitly specified a Templater to be used? That’s what use in shortcuts for non-periodic notes, and have used that to create periodic notes where I specific the file path and template; for example, when I create a daily note, I also create a tomorrow note so the daily notes has a note for the navigation (yesterday & tomorrow).

I will probably try that variation to see how that case works. Also, as you suggested, I suppose I might try the problematic shortcut in a test vault that only have Actions URI, Periodic Notes, and Templater to see what happens without any other plugins active.

I know I have been occasional problems where all the notes in an Obsidian vault suddenly go blank in the middle of editing them. If I close those windows, and re-open that same vault, they are restored right where I was after initializing everything again. This doesn’t affect other vaults that are also active. It’s a bit weird and annoying, but it has nothing to with this problem. However, maybe that also due to a rogue plugin.

Do you think it would be any different if I used Create file at path and explicitly specified a Templater to be used?

Yes, I think that’d work. Normally, I’d suggest using Templater’s folder templates for that but I guess that’d clash with your “tomorrow note”. (Sidenote: I’ve done the same in the past, i.e. adding a link to a future note but I never created that note, I just added the link, because I knew the next day it would resolve (after that daily note was created)).

I know I have been occasional problems where all the notes in an Obsidian vault suddenly go blank in the middle of editing them

That sounds like a visuals-related plugin or theme going haywire. Thankfully, I’ve never experienced that! :sweat_smile:

I tried creating the Day note using Create File at Path, but that failed to process the Templater user scripts just like Create Daily Note earlier.

I might develop another version of these templates that includes all the JavaScript within a single code block at the front before frontmatter rather than using multiple user scripts. I was trying to modularize it somewhat so maintenance might be easier with several smaller scripts rather than one big one.

Actually, I currently have too many user scripts, and I’m trying to get them more organized so they can be used across multiple templates and scripts. I’ve made some progress on that more recently, but it still needs some more time.

I can’t use Folder Templates because I have a nested date subfolders under Calendar/Notes, such as 2025/03/26 (day), 2025/03/W13 (week), 2025/03 (month), 2025/Q1 (quarter), and 2025 (year). There isn’t a specific folder aligned with its associated template so I can’t define them in my situation.

Periodic Notes allows me to define the appropriate file path and name based on custom format, which I use, as well as a unique template for each time period.

Format: YYYY/MM/DD/YYYY-MM-DD
Template: x/Templates/Calendar/Periodic/Day/Note template - Day.md

YYYY/[W]WW/YYYY-[W]WW
Template: x/Templates/Calendar/Periodic/Week/Note template - Week.md

YYYY/MM/YYYY-MM
Template: x/Templates/Calendar/Periodic/Month/Note template - Month.md

YYYY/[Q]Q/YYYY-[Q]Q
Template: x/Templates/Calendar/Periodic/Day/Quarter template - Quarter.md

YYYY/YYYY
Template: x/Templates/Calendar/Periodic/Day/Year template - Year.md

They all have the same Folder Template: Calendar/Notes.

I suppose I could avoid creating a tomorrow note since that next navigation link would be resolved when the day notes is created on the following day. I guess I had problems in the past where I clicked on a placeholder link for tomorrow and it created it in my default notes folder (+/Notes) rather than Calendar/Notes.

For example, when I do a Day Review, and also do a Preview for the next day that includes my focus effort, top actions, schedule, and time blocks for tomorrow so I can get started right away in the morning after checking the plan. I think that’s when I started doing this so that link would always be valid (even today).

Regarding the sudden blanking of all open panes in a vault, I should probably report it to Obsidian since it might be difficult to track down if it’s a plugin culprit. Although it would be tedious, maybe I could disable suspect plugin candidates, and see if the problem disappears. However, that’s rather hit and miss and might take a while.

Okay, I tried this shortcut to create a Day note using Create note at file path with a Templater template that included the user script commands that were successfully resolved after inserting a 2-second delay and then using Open Obsidian Note before the Trigger Command to Replace templates in the active file. So this worked (maybe it doesn’t need to be 2 seconds, but I wanted to give it enough time to finish just to be save).

It might be interesting to see if this same technique also works with Create Daily Note, so I might give that a try too.

Doug Warren

Okay, now I’m getting it to work using Create Daily Note also when I defer Trigger Command after a 1-second delay from Open Obsidian Note toward the end of the Shortcut workflow from Create Daily Note.

During my testing, I had some weird behavior where I thought it created it, but then Open did not find it. After further digging, I realized that had accidentally specified both DayNote and DayTemplate as strings rather than Shortcut variable names for Text actions where I constructed the file path for the note and template.

So I’m not crazy after all. I thought you might like to know.

Doug Warren

To wrap this up, after creating the Day note using Create Daily Note, now I’m also creating a Tomorrow note using Create file at path. So it’s all good now.

Doug Warren

1 Like

FYI, Templater 2.10 (?) introduced “File regex templates”, so what you’ve described is doable now:

Just in case you haven’t seen them yet… They were new to me, I just discovered them.

Glad to hear you got the rest of your setup working! :vulcan_salute:t3:

Interesting. I was not aware of that new feature in Templater. I don’t actually think it would be used in my situation since periodic notes are not “empty”.

If I understand this right, an AFO Create Note action would cause Actions URI to create create a new periodic note via Periodic Notes based on the Note Folder and Format setting with the syntax reference, and it use the specific Template for that periodic note. So it seems to me that it would be Periodic Notes that would use the specified template for that new periodic note, not Templater.

However, this would not be an “empty” note as mentioned for Templater folder or regex templates, so I don’t see how they would be invoked. In Templater Settings, it says they “are triggered when an empty file is created in a given folder”, and then “Templater will fill the empty file with the specified template”. So it seems to me that these Templater settings would only apply when you simply created an empty file in a matching folder; if using regex folders, then it would apply when the format of that empty file matches the regex expression.

When that Periodic Note template has Templater statements that need processing, it’s the Templater setting “Trigger Templater on new file creation” that causes Templater to be activated on the “new file creation event” (caused by the new Periodic Note) to process and replace any embedded Templater statements (like I had for user scripts).

It’s late and it’s been a long day, so just a quick answer:

I’d set up Periodic Notes to create empty notes – i.e., configure it w/o specifying templates in PN, only set format and note folder. Then, I’d configure Templater and it’s File regex templates to react to the creation of the new empty notes (created by PN).

Basically, the “periodic” templates would be set as part of the File regex configuration in Templater, then.

And yes, AFO would call Actions URI w/ the task to create a new daily/ weekly/ etc. note, which would hand the task to the aforementioned obsidian-daily-notes-interface library, which would create the note according to Periodic Notes’ configuration.