It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence 5.3 String comparing Excerpts isn't working

In Confluence v.5.3, I'm trying to write a User Macro that creates a table from my index page's children. Each child page has an Excerpt macro in it that I need to add to the index page's table. From my User Macro, the excerpts are being pulled out by calling Excerpt-Include within my macro. They are printing quite fine on the table.

My problem is I can't seem to use the excerpts within an if-else comparison. For whatever reason, it's not comparing them because of a type incompatibility or I'm writing it incorrectly. This is what I am attempting to do:

#set($macroFinal = "{excerpt-include:" + $page.getTitle() + "|nopanel=true}") #set($myexcerpt = $action.getHelper().renderConfluenceMacro($macroFinal).replaceAll('"', '"') + " ") #if($myexcerpt == "High") #set($colors = "#F0F0F0") #else #set($colors = "#FFFFFF") #end 

Any idea how to get the comparison to work?

1 answer

1 accepted

0 votes
Answer accepted

Well, I feel a little silly now. After some more fiddling with it, it turns out I just needed a "toString" on the end of the macro call.

#set($myexcerpt = $action.getHelper().renderConfluenceMacro($macroFinal).replaceAll('"', '"').toString())

Worked perfectly fine after I got that in. So, note to everyone, when in doubt, toString. XD

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,502 views 6 6
Join discussion

Community Events

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

Events near you