Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Automation: Create a new Page from Template as a Child Page of the Publish Page Trigger

I've spent several hours on this so I thought I would take a step back and ask for help.  

 

On Confluence, each product our org works on has the same child page structure.  For the sake of creating an example let's say this is the structure:

A - Company Products

        A.1 - Perfect Product Name

                A.1.1 - Perfect Product Name Requirements Document

                A.1.2 - Perfect Product Name Creative Assets

                A.1.2 - Perfect Product Name Guides

 

What I've been trying to do is create an automation, so that if I create a child page to "A - Company Products", for example the "A.1 - Perfect Product Name" page in the above example.  That A.1.1, A.1.2, and A.1.3 will all be automaticallhy created from template as child pages to the newly created "A.1 - Perfect Product Name".

I've tried everything I can think of including trying to use confluence APIs with the "Send web request" automation, and the best I can do is create a generic file from template in a folder who's name I know, that already exists.  Could anyone help me use Confluence automations to automatically create these child pages?

Any help would be greatly appreciated :) 

 

 

1 answer

Hi Joel,

You might be able to built something like this with our addon JavaScript Button for Confluence . Add a JavaScript Button to the very top of your Product Page and a field for the products name, like so:

Screenshot 2023-11-12 at 19.16.25.png

Use the following code:

function createProduct(page, productName) {
const body = JSON.parse(page.body.atlas_doc_format.value);
const extensionKey = body.content[0].attrs.extensionKey;

return {
parentId: page.id,
spaceId: page.spaceId,
title: productName,
body: {
representation: "atlas_doc_format",
value: "{\"type\":\"doc\",\"content\":[{\"type\":\"extension\",\"attrs\":{\"layout\":\"default\",\"extensionType\":\"com.atlassian.confluence.macro.core\",\"extensionKey\":\"children\",\"parameters\":{\"macroParams\":{},\"macroMetadata\":{\"macroId\":{\"value\":\"47ab8f0b-766b-46f6-af0b-6c377c1f699d\"},\"schemaVersion\":{\"value\":\"2\"},\"title\":\"Children Display\"}},\"localId\":\"5ab88798-faf9-47ff-84b6-79f7e4a95c2c\"}},{\"type\":\"extension\",\"attrs\":{\"layout\":\"default\",\"extensionType\":\"com.atlassian.ecosystem\",\"extensionKey\":\"" + extensionKey + "\",\"text\":\"JavaScript Button (Staging)\",\"parameters\":{\"guestParams\":{\"resultLocation\":\"$page\",\"code\":\"async function createChildren(page) {\\n const productId = page.title.substring(0, 3);\\n const productName = page.title.substring(6);\\n return [{\\n parentId: page.id,\\n spaceId: page.spaceId,\\n title: productId + \\\".1 - \\\" + productName + \\\" Requirements Document\\\",\\n body: {\\n representation: \\\"atlas_doc_format\\\",\\n value: '{\\\"type\\\":\\\"doc\\\",\\\"content\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"content\\\":[{\\\"text\\\":\\\"Add requirements.\\\",\\\"type\\\":\\\"text\\\"}]}],\\\"version\\\":1}',\\n }\\n },{\\n parentId: page.id,\\n spaceId: page.spaceId,\\n title: productId + \\\".2 - \\\" + productName + \\\" Creative Assets\\\",\\n body: {\\n representation: \\\"atlas_doc_format\\\",\\n value: '{\\\"type\\\":\\\"doc\\\",\\\"content\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"content\\\":[{\\\"text\\\":\\\"Add creative assets.\\\",\\\"type\\\":\\\"text\\\"}]}],\\\"version\\\":1}',\\n }\\n },{\\n parentId: page.id,\\n spaceId: page.spaceId,\\n title: productId + \\\".3 - \\\" + productName + \\\" Guides\\\",\\n body: {\\n representation: \\\"atlas_doc_format\\\",\\n value: '{\\\"type\\\":\\\"doc\\\",\\\"content\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"content\\\":[{\\\"text\\\":\\\"Add guides.\\\",\\\"type\\\":\\\"text\\\"}]}],\\\"version\\\":1}',\\n }\\n }]\\n}\",\"functionName\":\"createChildren\",\"cqlQuery\":\"\",\"caption\":\"Create Child Pages\",\"parameters\":\"$page\"},\"localId\":\"4839322d-e0c3-4ff9-9901-e14733e0bfab\",\"extensionId\":\"ari:cloud:ecosystem::extension/" + extensionKey + "\",\"extensionTitle\":\"JavaScript Button (Staging)\"},\"localId\":\"19454fdd-7ab4-40c9-882a-f09b95a2f549\"}},{\"type\":\"paragraph\"}],\"version\":1}"
}
}
}

 

Regards, Benno

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events