Forums

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

How to compare integer parameter in a confluence macro?

Mario Muetze July 30, 2020

I'd like to use an integer parameter that represents a percentage and thus cannot be higher than 100.

First I hoped type "percentage" would perfom some checking of that, but it doesn't.

Than I tried to check that maximum value by code, but apparently all comparisons like <, <=, >, >= will not work. I guess, that is because of "Confluence accepts this type, but treats it in the same way as 'string'."

Has anybody a suggestion, how to overcome this?

We use Confluence 6.12.

Thanks for any help!

1 answer

1 accepted

1 vote
Answer accepted
Mario Muetze July 30, 2020

After posting this Question, there was the following link under "Related Community content":

https://community.atlassian.com/t5/Confluence-questions/Using-user-macro-parameters-as-integers/qaq-p/811828

I adopted the answer of  @Davin Studer (thank you, Davin!) and that solved my problem.

It now works like that:

#if ($generalUtil.convertToInteger("$percent")>100)
#set($percent=100)
#end

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
6.12
TAGS
AUG Leaders

Atlassian Community Events