Create child page from template with prefilled title
Asked by Deniz Perz:

Hello!  
I have a parent page named "page 1".  
On it I want to place the "Create from template" button.  
At the same time, I need that when the "Create from template" button is pressed, a child page is created with a pre-filled title, for example (Documentation + page 1). That is, the title of the child page should automatically fill in the title with two variables, this is an arbitrary text + the title of the parent page.

What solutions are currently available? How can I implement it?


Answers:
author: Patrick Vanhoof
body: I do not think this is possible with the 'Create from template' macro.

We have the Scriptrunner for Confluence add-on, that has a 'create page' macro with lots of possibilities.

comments: author: Marianne Lee _Nagarro_
body: Hi [@Patrick Vanhoof](/t5/user/viewprofilepage/user-id/1131759), do you know I can create a new page from a template while passing a custom variable $myVariable to the template to generate content? At the same time the page title uses $myVariable as a prefix, how can this be done without having to enter the value twice for $myVariable? Can this be achieved using the "Create Page" macro by ScriptRunner ?


author: Patrick Vanhoof
body: [@Marianne Lee](/t5/user/viewprofilepage/user-id/3502437) , the variable in the template works as with the create from template macro, you get a screen first where you enter the variabler value.

But as far as I can see, the use of that variable in the Create page macro is not possible. Correct, [@Jessie Wang_ScriptRunner_The Adaptavist Group](/t5/user/viewprofilepage/user-id/4583003) ?


author: Jessie Wang_ScriptRunner_The Adaptavist Group
body: Hi [@Deniz Perz](/t5/user/viewprofilepage/user-id/5052372) are you on an on-prem instance? If so you can achieve this with ScriptRunner for Confluence and our 'Create Page' macro as mentioned by Patrick above.

In our documentation, there is a short 1:30min video that will give you a demo of what the macro does. You can watch it to see if it meets your needs. <https://docs.adaptavist.com/sr4c/latest/features/macros/built-in-macros/create-page>.

ScriptRunner for Confluence is available for a 30-day free trial if are interested in testing it out. [https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?tab=overview\&hosting=cloud](https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?tab=overview&hosting=cloud)

Any other questions feel free to ask!

comments: author: Marianne Lee _Nagarro_
body: Hi [@Jessie Wang_ScriptRunner_The Adaptavist Group](/t5/user/viewprofilepage/user-id/4583003) , I have ScriptRunner for Confluence (server) and exploring the possibilities with extending the "Create Page" macro by ScriptRunner.

My goal is to create a new page from a template while passing a custom variable $myVariable to the content body from page template. At the same time the page title uses $myVariable as a prefix.

1. Is it possible to create a custom class to extend the CreatePageMacro? I've not been able to succeed as described in [Customising Macro Variables](http://confluence-addons.connect.adaptavist.com/create-page/latest/macro-customisation.html). Do you have any code examples?

2. Is it possible to grab a value from a table in a current Confluence and pass it on to CreatePageMacro?

otherwise,

3. Can the value from \<Prompt Title\> in "Create Page" macro be passed to a page template?


Tags: confluence-server

server