Confluence page created from template via automation rule does not have label applied
Asked by Dan Regan - ReleaseTEAM:

Is anyone creating pages from template via automation rules and having their labels applied correctly?

I have a template for creating a page that includes the application of a label. If I use this template via the /create macro on an existing page, my new page is created with the label correctly applied. However, if I use the same template to create a page as part of the action sequence for an automation rule, the page is created, but the label is not applied.

Note that this is consistently reproducible. I can create via the automation rule, and the label is not applied. I can then create via the /create macro, and the label _is_ applied. (This leads me to conclude that there is nothing wrong with the template itself.)

Every time I try via automation rule = no label

Every time I try via /create macro = label applied


Answers:
author: Marc - Devoteam
body: Hi [@Dan Regan - ReleaseTEAM](/t5/user/viewprofilepage/user-id/5283434)

What does your rule look like?

Are actioning the rule from Jira or Confluence?

comments: author: Dan Regan - ReleaseTEAM
body: Hi [@Marc - Devoteam](/t5/user/viewprofilepage/user-id/3796976)

Jira does not factor into this. It's a simple rule that triggers on Confluence page edit. The rule checks the page status and whether a specific label is applied to determine if action is required. This part is all working as needed.

When action is determined to be required, the rule will remove the label that helped to trigger the action. (We only want it to fire once, and this helps to ensure that.) Additionally, a new page is created via template, and the rule is creating this page where we expect it to be.

The issue is that the template is defined to attach a label to the page it created. If we create a page from the template via the /create macro, the new page _does_ have the label applied. If we create a page from the template via the automated rule, the new page _does not_ have the label applied.

I suspect this is a bug related to page creation via template during rule execution. I'm wondering it anyone else out there is trying to create new pages via automated rules with templates that apply labels. If so, are they seeing the same behavior, or is there something that needs to be done differently on my side?


author: Marc - Devoteam
body: Hi [@Dan Regan - ReleaseTEAM](/t5/user/viewprofilepage/user-id/5283434)

An option is to use the "Branch rule / related entities" component in conjunction with the publish new page trigger. This will create a CQL search and execute the action applied within the branch rule on every result (for up to 100 results).

This could help you apply the labels to pages that just created.

Or create a new rule that can be triggered by the previous rule, use a CQL clause to find the previous created page and then add the required label.

Hopefully this might help you in finding the solution


author: Dan Regan - ReleaseTEAM
body: Hi [@Marc - Devoteam](/t5/user/viewprofilepage/user-id/3796976)

I'm playing around a bit with this, and I'm hoping you've lead to the path of a solution! :)

In previous testing, I've discovered that the order in which actions are executed appears to be important. With additional testing, I think I may better understand how this is working. When my rule executes, it performs actions in this order:

1 - Remove a label  
The rule is configured to run when a) the page is edited, b) it has a specific label applied, and c) it has a specific page status. The rule removes the label because we only want the trigger to fire once. (After it fires once, we don't want it to fire on future edits.)  
This works as required.

2 - Create a new page  
Next, it creates a new page via template. This *mostly* works - with the exception that the label to be applied via the template is missing.  
This is the original problem I reported.

3 - Create a label  
I modified the rule to add this third action of applying the "missing" label. Of course, the Rule wizard provides no mechanism for specifying the page to update. My presumption was that this would be applied to the existing page that triggered the rule, but I'm happy to report that the label was applied to the *new* page - resolving my issue!!!

The moral of the story is that the order of the actions is important!!!

It would appear that when the rule first starts, actions to update a page (label additions/removals, etc) will apply to the page that triggered the rule. If the rule creates a new page, the "context" for subsequent page updates (label additions/removals, etc.) changes internally to this new page! Therefore, any changes to be made to the existing page need to be performed before the new page is created.

Can anyone confirm that this is the *intended* behavior? I'd hate to think that it's only working because of a bug that might be fixed in the future.


author: Marc - Devoteam
body: Hi [@Dan Regan - ReleaseTEAM](/t5/user/viewprofilepage/user-id/5283434)

This is indeed intended behavior. The order you have an action or actions execute in a rule is certainly important.

Actions can't based upon a new creation must be after the creation, as otherwise is nothing to action too.


author: Dan Regan - ReleaseTEAM
body: [@Marc - Devoteam](/t5/user/viewprofilepage/user-id/3796976), Thanks for confirming!  

While this doesn't answer the question regarding why the label is not applied via template when executed as part of a rule, it does provide a simple alternative for accomplishing it. I'm accepting this as the answer. Thanks again!


author: Thibaut Subra _Elements_
body: Hi [@Dan Regan - ReleaseTEAM](/t5/user/viewprofilepage/user-id/5283434)

If you're not against using third-party apps, you can use our [Elements Publish](https://marketplace.atlassian.com/apps/1225519/elements-publish-create-confluence-pages-from-jira-issues?tab=overview&hosting=cloud&utm_source=community&utm_medium=forum&utm_campaign=question-2438689) application that will help you with that.

You just have to create a recipe where you choose where, how and what do you want to copy from Jira to Confluence (here is how you can [copy and add a label](https://doc.elements-apps.com/publish-to-confluence/how-to/add-labels-to-confluence-pages-created-from-jira?utm_source=community&utm_medium=forum&utm_campaign=question-2438689)).

![](https://doc.elements-apps.com/publish-to-confluence/files/24420806/24420807/1/1627545402000/copy-labels-and-publish-to-confluence.png)

And if you want to keep your Automation rule, you can trigger your recipe [directly from Automation](https://doc.elements-apps.com/publish-to-confluence/how-to/create-confluence-pages-with-automation?utm_source=community&utm_medium=forum&utm_campaign=question-2438689).

![](https://doc.elements-apps.com/publish-to-confluence/files/58591050/58591051/1/1662367518000/send-web-request.png)

Don't hesitate to give it a try, our app is free under 10 users and we have a 30-Day trial policy.

I'll be glad to help if needed!

Regards

Thibaut

comments: author: Dan Regan - ReleaseTEAM
body: Hi [@Thibaut Subra _Elements_](/t5/user/viewprofilepage/user-id/5183563)

Thanks for taking the time to reply, but it looks like your app is designed to enhance the Jira/Confluence integration. This issue I'm facing is 100% Confluence. I suspect it's a bug with how the automation rules create pages via templates. For some reason, it appears to fail to apply the label defined within the template. I'm curious to see if others have seen similar behavior, or if it's "just me"...


author: Thibaut Subra _Elements_
body: Oh ok, sorry for that, I thought it was from Jira to Confluence. It indeed looks like a bug because it has no reason to work differently with Automation.


author: Kelly Wehbi
body: I'm trying to create an automation from Jira to Confluence, where a Confluence template that has labels is triggered off a Jira automation. Same problem. The labels don't get applied unless I use the template when manually creating a page in Confluence.


Tags: cloud

confluence-cloud