Conditional formatting in Confluence

Hi All,

we need a macro or plugin which enables us to create conditional fields. Just like Excel does: based on the value of a field, another field will be set to a custom value. More specifically our management likes the green-yellow-red status macro and we'd like to implement that based on the value of a field then the status will change to green (good) or red (bad). Is it somehow poosible?

Thanks in advance,


1 answer

1 vote
Davin Studer Community Champion Jun 30, 2014

What do you mean by field? Is this something that is enetered by a user, is it changed automatically by some system, is it getting it from a web service? How is the "field" data changing?

As far as the status maco is concerned you could change that on-the-fly with Javascript after page load by simply adding or removing a CSS class to the element.

Color        CSS Classes
Grey         status-macro aui-lozenge
Red          status-macro aui-lozenge aui-lozenge-error
Yellow       status-macro aui-lozenge aui-lozenge-current
Green        status-macro aui-lozenge aui-lozenge-success
Blue         status-macro aui-lozenge aui-lozenge-complete

Hi Davin,

I mean that I would have a table in Confluence. There is a cell where I add number value. Based on this number another field would have various value: e.g. if the number cell has value of 100 then the other value gets text value: Good, if the number cell has value of 30 then the text cell gets value of Bad.

Sorra for confusing you with fields. In fact there are no fields in Confluence, it's JIRA:). I talk about a table in Confluence.

Thanks in advance,


Davin Studer Community Champion Jul 02, 2014

Does the value entered need to persist over page reloads, or would it be enetered everytime the page is accessed?


the value would be updated in every 2 weeks: so in every 2 weeks this particular page would be edited. I hope that helps.

Davin Studer Community Champion Jul 07, 2014

So, just to be clear would you be editing the page(in edit mode) and putting data into a table. When the page is saved based on the data in the table you want to have a status macro updated to reflect a formula calculation?

Hi Davin,

yes, exactly!

Davin Studer Community Champion Jul 07, 2014

This could be done then with a user macro and a little bit of javascript. Here is a down and dirty example. You will have to fill out the formula logic yourself.

Macro Name:

Macro Title:
Macro Title

Macro Body Processing:


## Developed by: Davin Studer
## Date created: 07/08/2014
## @noparams

#set( $id = $action.dateFormatter.calendar.timeInMillis )
<div id="table$id">
        <ac:structured-macro ac:name="status">
            <ac:parameter ac:name="colour">Grey</ac:parameter>
            <ac:parameter ac:name="title">Grey</ac:parameter>
<script type="text/javascript">
    var results = 0;
    // Code here to set the results variable based on your formula.                //
    switch (results) {
        case 1:
            AJS.$('#table$id span.status-macro.aui-lozenge').addClass('aui-lozenge-error'); //Red
            AJS.$('#table$id span.status-macro.aui-lozenge').text('Red Text');
        case 2:
            AJS.$('#table$id span.status-macro.aui-lozenge').addClass('aui-lozenge-current'); //Yellow
            AJS.$('#table$id span.status-macro.aui-lozenge').text('Yellow Text');
        case 3:
            AJS.$('#table$id span.status-macro.aui-lozenge').addClass('aui-lozenge-success'); //Green
            AJS.$('#table$id span.status-macro.aui-lozenge').text('Green Text');
        case 4:
            AJS.$('#table$id span.status-macro.aui-lozenge').addClass('aui-lozenge-complete'); //Blue
            AJS.$('#table$id span.status-macro.aui-lozenge').text('Blue Text');

Davin Studer Community Champion Jul 10, 2014

Does something like this meet your needs?

Hi Davin,

it doesn't work at all.

Davin Studer Community Champion Jul 13, 2014

Well, you have to fill out the code to calculate the formula to change the macro class. Aside from that it should work.

Is it possible to convert JIRA data to colors when presented in Confluence using a similar script, or does the above script only work if you manually enter data into a table in Confluence? 

Example: We have a JIRA field 'Health' = At Risk, which would be associated as a YELLOW.  Our Confluence page uses JIRA Filter Results to present a status report that includes several fields, including Health.  We need to show the Health as Yellow on the Confluence page without manual data entry – just rely on the JIRA data.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

783 views 33 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you