Using a formula to set / change a page title

I think the answer to this is “no”, but…

The Use Case

I have a template which consists of a nest of pages, sub-pages and sub-sub-pages. About 10 pages in the template in all, but it could grow. Every time I instantiate this template (always into the same doc), I get another 10 pages in my doc with the same page titles as last time. Since the new set of pages relates to something … errr … new, I amend all the page titles to include a character string which tells me what they’re about (e.g. VM023), which makes them unique again. It’s nice not to have 23 pages in the same doc which are all called “Windows Settings”! So now I’ve got one nest where all the page titles contain VM001, one nest with VM002, … and one nest with VM003.

The manual effort involved in all these repetitive changes to page titles irks me. Isn’t this what computers are for?

The Idea

I want to be able to type the unique character string in somewhere, once, e.g. on the “top” page of the nest, and have formulae in each page title “calculate” a unique title for each page, based on the value I typed in (once).

Ironically, it seems that the title is just about the only place on a Coda page where typing “/” is possible, but does nothing. But it seems like the way Coda ought to “think”.

(Better still would be the ability to paramaterise the process of instantiating the template, along the lines of passing parameters into an object constructor. But now, I really am fantasising … )

Can anyone think of a way of doing this?

(I know I could probably get something similar with a canvas column in a table, but then I have to jump through hoops to express the nesting of the page hierarchy. )

Hi @James_Daniel :blush: !

So, I have 2 ideas to suggest :blush:

The easier one would probably be to use the Doc Explorer Pack and once setup, add the Doc Pages sync table.

Once the table has synced all the pages in your doc, included the duplicated ones you want to rename, you can add a text field to store/formulaically determine the new name for the pages you want to rename and then setup an Update Page button available in the pack :blush: .
Once you click on the button, it will tell Coda API to update the name of the page according to the chosen/calculated name :blush: .

or … for a semi-working idea, as this would still require you to intervene, you could use DuplicatePage() and a one row helper table such as the one you see in the sample below ([Duplicate Pages]) where each blue button is setup to duplicate a specific page from the “template” and name it according to the “name” field next to it :blush:

The purple button is there to push each individual blue button and update the value in the field [Dupl. Count] (as this used to name each duplicated pages).

Now, the thing is that I couldn’t find a way to name each individual duplicated page while still keeping the structure of the template … (as pages tends to be quite inflexible, I couldn’t simply reference a previously duplicated page as a parent for a page).
And this is why each page is created from the farthest position in the structure to the closest one under the page named Duplicated page… and this is where one would need to manually recreate the initial structure of the template :innocent:

Hello Pch,

Thanks for your reply.

I think you’ve understood the question and I’m grateful for your effort. :smiley:

With regard to the second idea first, I think that having to reconstruct the page heirarchy each time would make it too much work to be worth the extra complexity.

With regard to the first idea (second) - this looks very promising. I shall take a look at the pack you linked to. Did you create it?

It’s ironic that one can rename a page using the API, but not using a formula. Ho hum.

All the best


Hi @James_Daniel :blush: !

I honestly agree :sweat_smile: !

It would probably be easier if we had a thisPage object (similar to thisDocument) we could reference in some way :innocent: … or if DuplicatePage() would just accept “classical” page references (the @NameOfThePage one) instead of exclusively the one that can be used to be set as Value for new rows in a canvas column.
This was the only thing that prevented me to duplicate the pages while keeping the original structure :pensive:

I still just thought it might be worth mentioning it :blush:

No, @Scott_Collier-Weir did :blush: !

And I hope it will help you with this annoying renaming issue :grin: !

My pack should let you do just what you are looking for!

A combo of the DocPages sync table and UpdatePage button!

1 Like

Hi @Pch

I’m new to Coda, so I have to be careful not to jump to conclusions.

My impression so far is that the design philosophy when it comes to user-defined activity is generally spreadsheet-ish. In other words, an object can “contain” a formula which can alter that object, and nothing else can alter that object. There is no general assignment operator which allows one thing to set the value of another.

I’ve noticed some exceptions, which are not spreadsheet-ish. These seem to be implemented as “alter thyself” methods which formulae elsewhere can call in conjunction with a reference to the target object. But the range of types of target object which can be referenced (and hence subject to external alteration) in this way is limited.

Coda is supposed to be an even-handed mix of the best of doc and the best of database. But my impression is that this external referencing is heavily table-centric, so the automation on the doc side of things is not as rich.

I’m coming at this from OneNote, which provides no user-definable automation at all. So I’m in the “any love is good love” camp when it comes to what Coda can do. Nonethless, I’ve always worked bottom-up (I think it’s called “Need-Driven Development”), where I put stuff in ad hoc, and then add structure and levels of abstraction as and when they look like paying off. The rather database-centric way of doing automation that Coda has feels as though it’s pushing in the other direction - you can suddenly do a whole lot more once you have a sufficiently high-octane problem to make it worth working within the relational paradigm. Meanwhile there are things it “should” be possible to do with much lower levels of structure and abstraction - particularly in the doc domain.

A simple grid control is another example. You can have a relational table, or you can have a text divided into columns (where there is no concept of a row). But no grid.

Enough philosophising for now…

Hi @Scott_Collier-Weir

I’ve had a look at the spec, and that seems to be exactly the case. :smiley:

Only snag is that I’m on the freebie plan at the moment, and I don’t seem to be allowed to get this pack until/unless I’m on Pro.

There are various other things in Coda that I need to poke before I take that step.

Let us know if you have any questions to help you figure out whether or not that steps worth it!

1 Like

Hi Scott,

I noticed that there is a “Trial” button on the pack - free for 14 days, so I gave that a go. I’ve got through the basic set-up, to the point where I can update a single page Name with a literal string value.

Here’s my write-up of the hurdle I am now facing.

We have a nest of newly-created pages. The object is to replace the text “[XXX]” wherever it occurs in each of the page titles, with a text value.


There is a control “Tedt New VM ID” on the canvas which allows the user to enter a number. This is the number on which the replacement text value will be based.



Tedt New VM ID =1 ; replacement text =”001” ; This is equivalent to

LeftPad(ToText([Tedt New VM ID]),3,“0”)

Then we need a string substitution, so that

“VM[XXX]” → “VM001” ; “VM[XXX] Windows Settings” → “VM001 Windows Settings” etc.

There is an instance of the Doc Explorer “Update Page” button on the canvas.


At present, I am only trying to get it to update the title of one page - in this case the one initially titled “VM[XXX]”.

The ID of that page (from the Doc Explorer DocPages Table, after adding that column) is entered in the PAGE ID box


I want to alter the page NAME, so I add that box:


I need to form a formula to put in this box. The formula needs to retrieve the current value of the page Name, perform a string substitution on it, then assign it back to the page Name*. This is straightforward, except that I can’t see how to retrieve the current value of the page name. The formula needs to be like this, except that I can’t find what to put where PageName occurs:

substitute(PageName,“[XXX]”,LeftPad(ToText([Tedt New VM ID]),3,“0”))

This needs to be a reference to the Name attribute of the page referenced by canvas-Y1GA95W1_V

Can I form such a reference in this formula box, and if so, how?

If this can be done, I then want to extend this technique so that I am referring to the entire list of pages whose names currently contain “[XXX]”, performing the substitution on each of them, and assigning the correct modified string value to each. In other words, change them all with one button push.

  • A previous version of this formula succesfully assigned a constant string value “VM001” to the page Name. So I know that the assignment part of it works.

Share the doc! Happy to help you out and much easier with the shared doc

I haven’t shared a doc before. I have seen other Coda docs shared on this forum, so I think I know what it should look like when it’s done right.

This is a link to it, but it doesn’t look right:

Example of DocPages table & Update Page button

I did this by using Coda to copy a link to the doc, then pasting it into the forum as a Hyperlink.

Maybe I need instruction on doc-sharing…

A link is enough! Just make sure the share settings on your doc are “anyone with the link Can edit”

You can set those permission by pressing the blue “SHARE” button in the top right of the doc


Share settings now amended - anyone with the link can edit.

Pls be gentle with it - this is a real doc (albeit rather simple as yet), not a minimal failing toy.

Hey there!

Hoping this screenshot gets you where you need to be

What I did was create a new control called a “relation” in Coda to choose the page to update. Then, in the button parameters I reference that new control to dynamically access

  • The canvas-id of the page I need to update
  • The current NAME of that page so I can simply replace the [XXX] with the new input

Let me know if you need any other help!

1 Like

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