Can I trigger a template from a link?

Robin Vessey March 6, 2013

I am trying to setup a series of templates for users to fill in with Confluence (ondemand).

I want to be able to trigger the creation of a new sub page based on a specific template so that the user can simply click "New XXX" on an existing page and create a new page based on the appropriate template.

6 answers

5 votes
Bruno Rosa
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2013

Robin, I think you can. You just have to catch the URL of the create page of the targeted template and display it on the page you want. The URL will be something like this:

- https://testing.atlassian.net/wiki/pages/createpage-entervariables.action?templateId=950273&spaceKey=AS&newSpaceKey=AS&fromPageId=622596

With that you will be able to create a link to point the user directly to the creation page from that template.

Cheers.

Nabil Sayegh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2013

I always get a 404 as soon, as I append parameters to the action. Are you sure, it works that way? I investigated some time on this a few days ago, and it only worked without template.

e.g. I try:

https://www.example.com/testconfluence/pages/createpage-entervariables.action?templateId=7733282&spaceKey=AS&newSpaceKey=AS&fromPageId=557070

(The ids are correct)

Robin Vessey March 15, 2013

Ok this is looking promising, does anyone know if I can use variables eg. @currentpage and @currentspace?

This would make it far more usable and extensible as templates wouldn't have to be edited with knowledge of internal IDs.

roam_scott
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2018

This doesn't work for me.  When I try to capture it by creating via the + icon, it goes to one URL and quickly redirects to a new URL.  I'm unable to capture the first one.  The second one looks like this:

 

https://<site>.atlassian.net/wiki/spaces/DOC/pages/create?templateId=45580314&title=&newSpaceKey=DOC&draftId=45514800

 

That obviously doesn't work due to the draftId. I tried removing that, and it still does not work properly.  It goes to a page that says "Something has gone wrong" then redirects to the new page creator.

ali.kansso July 23, 2018

We tried this link format and it worked for us. We're on Confluence Server

https://<siteURL>/pages/createpage-entervariables.action?templateId=<templateID>&spaceKey=<SpaceKey>

Like # people like this
Michael Rosenthal February 19, 2021

Where do I find the templateID?

Josh Carpenter March 24, 2021

You can find the template ID with the little JavaScript snippet below:

1. Click the three dots next to "Create":

create.png

2. Select the Template for which you need the ID:

select.png

3. Hit the F12 function key on your keyboard, this opens up your browser's development console; on the "Console" tab, enter the following code snippet:

document.getElementsByClassName("template selected")[0].getAttribute("data-template-id")

4. The ID will be displayed on the next line:

console.png

Note: this was tested in Chrome v89 and Firefox 86. Not tested in other browsers, but likely to work.

Hope this helps!

Josh Carpenter March 24, 2021

The URL noted above by @ali.kansso works perfectly in Confluence server.

With one additional parameter, you can also add a pre-populated title to the newly created page:

https://<siteURL>/pages/createpage-entervariables.action?templateId=<templateID>&spaceKey=<SpaceKey>&title=<Your+Preset+Page+Title+Here>

(Note that that plus symbol (+) represents spaces.)

0 votes
Monique Khairuliana[ServiceRocket]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2021

Hi @Robin Vessey 

Linking for Confluence by ServiceRocket have this functionality that you're looking for via its key macros, Add page & Add page via form macros.

They are like a supercharged version of Confluence’s “Create from template” feature. Rather than asking your users to manually create pages from a template, you can use the Add Page macro to insert one-click links which will create a page based on a specific template (a Confluence template, or even a standard Confluence page!).

On top of that, you can also 

  • Specify a prefix or postfix for the page title, to establish a page title taxonomy
  • Specify page counter, so you can automatically number your pages
  • Specify its parent location in the space, so that everything will be located where it should be
  • Specify labels, so that you don't have to rely on your user to remember adding labels

Linking for Confluence is available on Server, Data Center, and Cloud.

Hope that helps!

Monique,
- ServiceRocket team

0 votes
Jonah Pressman December 2, 2020

Chrome DevTools should give you enough info to help you craft your URL accurately.

0 votes
Jürgen_Weber March 17, 2020

anyone have this working in my recent history?

0 votes
Christine C June 6, 2018

There is a Create From Template button which can generate a button for this

https://confluence.atlassian.com/doc/create-from-template-macro-317196995.html

Marco Chiarello June 22, 2018

@Christine CThank you for the tip. This is useful.

In my case, I need to enable users to create a page for a link if the page doesn't exist. Once the page is created (based on the right template), the ability to create the page is no longer necessary. Users may try and create a page that already exists, find the error and go back, or maybe change the title and create duplicates.

Can the macro be somehow disabled once the page has been created?

Christine C June 25, 2018

When creating a link, it's possible to link to an undefined page. See https://confluence.atlassian.com/confcloud/insert-links-and-anchors-724764900.html#InsertLinksandAnchors-Linktoanundefinedpage(apagethatdoesnotexistyet)undefinedpages However, I don't see an option to use a template with that link. That would be a really useful feature

Robin Vessey June 25, 2018

@Christine C can you show how to do this from a global template used across 2 or more spaces? 

By this I mean have a from a base page in a project space created from a global template have a macro button on the page to trigger the creation of child page using a second global template (and so on). 

eg. We have many projects, each project has a space, they all use the a common set of templates.  Each template has a series of "create page from template macro" buttons on them. This helps people keep the project structure easily.

Currently I cannot create a series of global template, available to all spaces, that enables these buttons to exist. 

Christine C June 25, 2018

I have not created a global page template before. It looks like you need special permissions for add/edit/remove those. 

0 votes
Deleted user November 22, 2016

No idea if this still is an issue for you but I think I've found an answer: if you remove the last part of the link, starting with "&fromPageId=" than I get a working link in my spaces. Additionally it appears that you can also delete "&title" and "&newSpaceKey". The "templateId" and "&spaceKey=..." seem to be needed to keep the link working. Kinda makes sense, not knowing the template ID nor the space to create the new page in will make it hard to create a page wink

roam_scott
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2018

Even with removing the other parameters, this still doesn't work correctly for me.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events