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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted 7 hours ago in United States

Atlassian Government Symposium

Good day members, Not sure if you are aware that Atlassian will be hosting a Government Symposium on May 1st, 2019 in Washington DC. For more details please click here If you have any questions...

13 views 0 0
View post

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