Create a Note with a Date in the Title - Why is this so hard?

What I’m trying to do

I don’t use Obsidian daily, but I do like to use it occasionally to log inspection results. What I would like to end up with is a folder of daily notes and a folder of inspection results. The Daily Notes folder currently works as expected - when I open Obsidian, I am taken to today’s Daily Note, which is based off of a very simple template.

What I can’t seem to get to work are the inspection result links. Ideally, the Daily Note template would create a page link with the format YYYY-MM-DD Generator Room. Most of the time, that page will not exist when the Daily Note is opened (i.e. it’ll be an unresolved link), and when clicked it should create the note titled YYYY-MM-DD Generator Room using the associated template.

However, occasionally, that note will already exist (i.e. if I’ve navigated back to the Daily Note for some reason, or if I’m looking for results from a specific date using Daily Notes folder instead of the Inspection Results folder), and clicking the link should take me to the existing page.

Things I have tried

I have tried using a combination of the Core Daily Notes plugin and Templater to achieve the result I’m looking for and I can’t seem to figure it out. Things that don’t currently work: I can’t create the unresolved link using the format I want (i.e. YYYY-MM-DD Inspection Name). I can create an unresolved link using plain text (i.e. Inspection Name) and rename it using Templater to the format I want, but if I navigate back to the Daily Note later and click the link again I get an error saying the note already exists (instead of being taken to the note). I assume this is because Templater is trying to rename the note to a name that already exists.

I am using Obsidian on mobile, so I can’t use scripting, I think.

I’ve tried this: [[Hatteras 61 CPMY/Maintenance/Inspections/{{today}} Generator Rm | {{today}} Generator Room]] and it gets me a note titled {{today}} Generator Room, which isn’t useful.

Seems like something you should be able to do with Templater. Here’s an example of one of my templates for an ‘Event’. It prompts me for a few things, creates a file and then renames it, and fills in a bunch of stuff based on the data it gathered. Some of this should work towards your goal:

let description = await tp.system.prompt("Describe the event","");
let inputDate = await tp.system.prompt("What is the date for the event?",'YYYYMMDD')); 
await tp.file.rename(inputDate + " - " + description); 
let hyphenedDate = inputDate.replace( /(\d{4})(\d{2})(\d{2})/g, "$1-$2-$3") 
title: <% description %>
startTime: <% await tp.system.prompt("When does the event start?","16:00") %>
endTime: <% await tp.system.prompt("When does the event end?","17:00") %>
date: <% hyphenedDate %>
fileClass: Events
created: {{date:YYYY-MM-DDTHH:mm:ssZ}}
filename: <% description %>

# <% inputDate %> - <% description %>

You’re using a template variable that doesn’t exist. Try this instead:

[[Hatteras 61 CPMY/Maintenance/Inspections/{{date}} Generator Rm | {{date}} Generator Room]]

This is a core template thing, not using Templater.

Perfect - thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.