We use JIRA cloud in BT.
Based on the number of issues in a project, I want to show assign a colored status / label in Confluence page. How do I do it ?
E.g. If no of issues with project "XYZ" is greater than 5, I want to have a status / label with a RED indicator on top of a confluence page
Hello there Rahul!
Currently, Confluence Cloud does not have a native method or macro to achieve this result. However, some REST calls can be used to perform this change.
The first step would be to create a page with a status macro and also the Jira issues macro with only one issue from the desired project. With the status macro, we will be able to control the color of it later.
After creating the page, it is time to GET the page content via REST:
This will allow us to get two sets of data, the project key from the issue macro and also the status macro data. The numbers and dash (-) should be removed from the string so we can use the key only:
<p><ac:structured-macro ac:name="jira" ac:schema-version="1" ac:macro-id="6f3f1181-9671-410c-90c4-a754f37523a2"><ac:parameter ac:name="server">JIRA</ac:parameter><ac:parameter ac:name="serverId">9de8af3e-0937-3d4b-8e79-933a2124cd43</ac:parameter><ac:parameter ac:name="key">WAG-11</ac:parameter></ac:structured-macro></p>
The value we need is under the ac:name="key" parameter.
Then, we need to check the number of issues for this specific project:
The reply from Sayeed Ahmed is actually the one we are looking into right now. Using the key found under the issue macro we will be able to know how many issues the project has.
Lastly, we need to update the page content we got earlier to reflect the changes, based on the number of issues returned:
For this, you will need to change two parts of the status macro, the ac:name="title" parameter and also ac:name="colour" parameter:
<p><ac:structured-macro ac:name="status" ac:schema-version="1" ac:macro-id="ecd9b86f-ac08-43b4-b1d5-800900b291f1"><ac:parameter ac:name="colour">Red</ac:parameter><ac:parameter ac:name="title">DONE</ac:parameter></ac:structured-macro></p>
This change will be based of on the arbitrary set of rules you created. Your code for this script need to have this "hardcoded" or to fetch this list of rules from somewhere else.
The reason that all these steps should be scripted is to avoid executing those calls manually after a given time interval. You can create this script using python, for example.
Let us know if this helps out your objective!
Thanks Diego for coming back on this.
I'm not a developer rather a super user in my company and trying to build a utility which shows project RAG which should automatically update its color based on issue number.
I'm going through the above recommendation step by step.
Could you pls tell me where can I invoke the REST API on my confluence page.
My current position is both macros are added - I've added a status and one-issue from a project.
Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events