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 :)
Aright so I managed to eventually figure this out but it was not a simple solution. I decided to trigger the parent page creation with the "When: Manually Triggered" rule. The child pages are then automatically triggered with the "When: Page Labeled" rule. I had to create a separate automation for each child page I wanted to add. It's a painful solution but it does the trick.
Unfortunately, I can't find a nice way to share the automation here in a simple way, but I'll copy screen shots of the automations below in the off chance this can help someone else. Here are the steps I followed:
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:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.