Ability to reference name of document within the document

Hey!

I’d like to dynamically be able to reference the name of the document I’m working in.

Right now, I can reference some properties of the document, like created/modified datetime, and who has modified/created it through e.g.
thisDocument.Created()

It’d be nice if I could reference what the document is named through a function like:
thisDocument.ToText()

or simply:
documentName

3 Likes

Would this workaround work for you? Basically using the doc url? Or do you want to do more with this?

That kind of works, thanks! Only that it doesn’t give the flexibility of not being formatted as a link.

The simplest solution is probably just to define a variable for the name once when you create the project, and then reuse that in everywhere in the template. Then the name only has to be changed in two spots: in the document name, and in the first variable.

This doesn’t work in other places you’d want to use the document name.

For example, with automation that sends a GMail message, I’d like the subject to be something like

= "Open tasks from " + thisDocument.name

so it stands out in the mailbox.

2 Likes

.ToText() on references has unexpected behavior. As a user, I’d assume .ToText on a reference would return the name of the reference (for example, @SomeSection.ToText() should return the name of the section.) Instead, it returns a string that includes the Coda-internal reference information (for example,“SomeSection_suuGP”).

I would like to revive this request. It’s 2024 and I need this exact functionality:

I wish we could simply use thisDocument.PageName(), but “PageName expects parameter object to be a table, a control, or a canvas”. Let’s broaden the scope a tad!

1 Like