How to update Confluence Cloud pages with Comala status as lable
von Christian Kienzl
Precondition:
Confluence Cloud standard with Comala document management. No Script Runner or Automation. You need a valid AuthToken for your Confluence environment.
Target:
Selected pages should be displayed on a Confluence database page. The Comala status should be shown in one column.
Targetgroup:
The target group of this article are users whi interested to build workflows in Frends
Of course we offer you, in a direct conversation, a deeper insight into the world of Frends and the associated possibilities in Confluence Cloud!
Why don't use Script Runner?
A very good question is, why don't we just use Script Runner in our Jira environment to solve the problem? First, we need to ask ourselves, what is the problem?
The status of Comala cannot simply be displayed in an overview list. We need an auxiliary solution.
Why don't we use the Confluence page status to display it in the list?
As soon as the Confluence page status is changed, it triggers a page change. The page status would indeed be in the correct status before the change, but the Comala status would revert to review.
So, how can we solve the problem?
The best option is to use the page tags, as changing the tags does not trigger a page update from Comala.
Why not solve this with Script Runner? If we set up a Script Runner job, it can run a maximum of once per hour. Additionally, there were issues with results for more than 25 pages.
Our solution is Frends, because it can also be simple 😉
Build the Process
This process represents the functionality to attach the Comala status as a label to a Confluence page. I will explain this step by step.
Trigger and Confluence pages
You need this URL to get the right pages:
Next, we check if the attribute cw-status
is present in the metadata.
var.page.metadata.properties.ContainsKey("cw-status")
And we check if a workflow has been activated.
var.page.metadata.properties["cw-status"]["value"]["enabled"] == true
If either of these conditions is not met, no label is needed, and we can proceed directly to the next record.
In the next step, we assign the Comala page status to a variable and prefix it with "cm-" to indicate that it is the Comala page status.
For safety, we check if a variable was indeed provided.
Before we go through all the labels, we set a variable. If in the loop it turns out that there is already a label that we are looking for, meaning the status is correctly marked, then we do not need to set a new label.
Now we check if there are any labels on this page. If there are none, we can skip the verification and directly set a label.
In this loop, we check each label to see if it has our prefix "cm-". In the first step, we get the first three characters of the label. Next, we check if the label starts with "cm-".
Next, we check if the label that starts with "cm-" already has the correct status. If not, it should be deleted. If it already has the correct status, we set the variable indicating that the label already exists.
In the final step, we check if a new label needs to be set. For this, we have previously set the new variable. If this variable is true, then a new label must be set.
Execution Monitoring
In the monitoring, we can clearly see the decisions made in the process tree. In the first example, we see that the search for records was successful. A total of 200 iterations were executed. The first record does not contain any metadata related to cw-status
. Therefore, the rest of the process is not executed, and we can directly move on to the next record.
In the example of this record, we see that there are no labels on this page, so the verification of existing labels can be skipped, and we can directly add a new label.
Summary
To summarise, we can say that the implementation in frends was a good 50% faster than script runner. In addition, we were able to automatically handle issues such as execution once per minute and monitoring. Especially due to the limitations of Script Runner, an alternative like Frends is an absolutely sensible solution in terms of efficiency and cost savings. The reusability of the process for other customers is clearly given by the deployment to different agents and is an additional advantage.