Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence automation - Check if all tasks on page have been complete and edit status macro

Harry Lee September 24, 2023

Hi all, 

I'm trying to create an automation that will edit the status macro on a page when all the tasks on said page have been completed. 

Is this possible? 

Thank you! 

3 answers

1 vote
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 25, 2023

Hello @Harry Lee ,

Technically this is possible: it is up to you how to do it:

  • ScriptRunner script / listener
  • Custom listener for a page update
  • Custom code executed in some environment that checks page body via REST API and does its job when the criteria are met

I suppose the general approach would be to run the code when the new version is created (when checkbox is ticked, it creates a new page version) and  parse page body to check if all the  get all tasks from xHTML/HTML and if all tasks have 'complete' status that is set as the xhtml attribute:

<ac:task-status>complete</ac:task-status>
<ac:task>
  <ac:task-id>2</ac:task-id>
  <ac:task-status>complete</ac:task-status>
  <ac:task-body><span class="placeholder-inline-tasks"><ac:link><ri:user ri:account-id="xxx" /></ac:link> task here <time datetime="2023-09-28" /> </span></ac:task-body>
</ac:task>

 If all the ``` ac:task ``` elements have complete status then you can update the page and update the Status macro inner code (<ac:parameter ac:name="title">resolved</ac:parameter>).

 

<ac:structured-macro ac:name="status" ac:schema-version="1" ac:macro-id="c0849f79-ce68-46ba-8539-088974fc596a"><ac:parameter ac:name="title">resolved</ac:parameter></ac:structured-macro>
0 votes
Kathy Hart
Contributor
April 13, 2024

Is this possible using the built in Confluence Automation, or is it only possible with Scriptrunner or Forge? 

0 votes
Harry Lee September 28, 2023

@Andrii Maliuta - That makes sense in theory. How would one check if all ac;task status have been checked?

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2023

Please re-read the whole comment.

 If all the ``` ac:task ``` elements have complete status then you can update the page and update the Status macro inner code (<ac:parameter ac:name="title">resolved</ac:parameter>).

If the child parameter of the element contains 'resolved'.

Harry Lee October 2, 2023

@Andrii Maliuta apologies, I meant would you use an automation within confluence automation such as the send web request? I'm new to utilising the REST api so trying to learn as much as I can!

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 2, 2023

Hi @Harry Lee !

I suppose that the options are:

  • To listen for a page edit and check its body each time - if all the checkboxes are marked, then you can do the necessary work 
  • Create a standalone app that will run as a separate service and will check for pages bodies that you need (by CQL query, or space level, or by IDs) - it will trigger checking data by REST API and then perform what is needed

 

If I am not mistaken, usually Script Runner app (https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?hosting=cloud&tab=overview ) is used for the easy of automation as it has built-in listeners, behaviors, jobs, etc. 

Also, the custom addon can be created using Forge/ Atlassian Connect if you need some custom functionality.

Hope I did not confuse :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events