Using Awaited Tags as Note Name

What I’m trying to do

I’m trying to setup a template for my note-taking while in class and I’m already using a tp.system.suggester for the tags [Type, Class]. And I’d like for the name of the new note to be named “Type-Class-Date”.
I could put a second userInput or suggester but it would just be some unwanted redundancy.

so far I have <% tp.file.rename(tp.file.tags + “-” + tp.date.now(“DD.MM.YYYY”)) %> which display either “undefined-20.07.2023” or “-20.07.2023”, this code part is put below the suggester prompt

Things I have tried

I tried accessing the tp.file.tags as a normal array like tp.file.tags[0] to no avail.

Please post your template for review – it’s easier to help you when looking at the code.

Sure, here it is

---
author: "First Last"
Location: "School Name"
tags: <% await tp.system.suggester(["Class", "Project"], ["Class", "Project"]) %>, <% await tp.system.suggester(["Subject1", "Subject2", "Subject3"], ["Subject1", "Subject2", "Subject3"]) %>
Aliases: 
date: <% tp.date.now("DD-MM-YYYY") %>
title: <% tp.file.rename(tp.file.tags + "-" + tp.date.now("DD.MM.YYYY")) %>
---
## Subjects
## Links

As I’m already getting the user’s input on the tags line, I want to reuse those inputs on the title line instead of asking once more the exact same questions

Here we go:

<%_*
const type = await tp.system.suggester(["Class", "Project"], ["Class", "Project"]);

const subject = await tp.system.suggester(["Subject1", "Subject2", "Subject3"], ["Subject1", "Subject2", "Subject3"]);

const date = tp.date.now("DD.MM.YYYY");

const title = `${type}, ${subject} - ${date}`;

await tp.file.rename(title);
_%>
---
author: "First Last"
Location: "School Name"
tags: <% `${type}, ${subject}` %>
Aliases:
date: <% date %>
title: <% title %>
---

# Subjects

# Links

Cheers

1 Like

Thanks a lot ! Didn’t thought I’d have to go through vars to do that

1 Like

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