How to pass information to a duplicated page

With the new duplicate page action, it’s quite nice to be able to create a template of a page and duplicate it.

However, there is an issue with this approach. Sometimes you will want to pass information to the new page. For example:

  1. In a customer wiki that contains information about your customer, you’ll want to pass the customer name
  2. In a meeting doc, you’ll want to pass the current date (if you have a new page for each meeting)

This doc offers a (dirty hacky) solution to that problem.

Overview

The only information we can pass to the new page upon duplication is the name of the page.

Then we need a way to get the information out of the page title.

Here’s the doc for you to look at, below is a summary of all the tricks that were used.

1. Create a Button on your Template Page

This can be any button, it’s used to get the url of the page, but it’s nice if it does something. In this case, the button creates the new meeting.

2. Create thisPage formula


[yourButton].Url()

This is what we’ll extract the title of the page from.

3. Get thisMeetingDate

Now, create another formula called thisMeetingDate. It looks like this:

thisPage.ToText().Split("/").Last().Split("_").First().ToDate()

This formula extracts the date part of the url.
If the url is: https://coda.io/d/_dV-vk_8iWzc/Meeting-Template_su55M

  1. Convert it to text
  2. Split it along forward slashes “/”
  3. Grab the last bit Meeting-Template_su55M
  4. Grab the first part
  5. Convert it to a date

4. Create the New Doc Button

Under Action make sure to pass in the current date as the name of the new page:

DuplicatePage([Meeting Template], Today())

Done!

That’s basically all there is to it! You’ll notice the actual doc has a bit more to it, but that’s just so that it’s useful, this information covers the heart of what’s needed.

Doc is also published here:
https://coda.io/@connor-mccormick/simple-meeting-doc

5 Likes

This is excellent stuff. Adding your thisPage formula to my Notes template and the 2 buttons you describe has gotten me way closer to being able to use Coda as a note-taking tool (in addition to the 20 bajillion other things).

One thing I don’t understand though is the need for the “manual change” checkbox. I think I’m probably missing something in your own use case. If the “create new meeting” button is passing the page’s URL to the Meetings table, that table will always render the current resolved name of the linked page, right?

Good question!

Checking and unchecking that button updates the meeting date after changing the page title.

Try changing the title of the doc to experiment with it.

Due to Coda mechanics I don’t really understand, the formula to figure out the url of a page can be forced to update with checking or unchecking the box.

You can see that thisPage is actually more complicated than I made it look in the original post.

If([Changed Page Title?], [Create New Meeting].Url(), [Create New Meeting].Url())

Just allows you to update the meeting date after changing the title.

Ahhhhh, okay, that makes perfect sense. So you’re basically using it to force a UI refresh of sorts?

Basically, yes. Though I’m not sure how it works.

1 Like