Forums

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

After upgrade to 7.4.11, user macro not working with & symbol in enumValues in if conditions

Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2021

Hi,

 Before upgrading to 7.4.11, we had user macros with enum values as options with "&" symbol and they were working fine. But after upgrade we observe that user macro is not working when user selects the option with & symbol like "name&product".

When user selects "all" enum option in the macro below, it works fine and outputs 

Parameter  enum option = all

When user selects "name&product" enum option if condition does not work and outputs in the page - "Parameter  $PeriodQueryString" - which is not correct

Expected output on the page is "Parameter  enum option = name&product"

 

Sample custom user macro is like this

## This is an example macro
## @param GroupByField:title=Report grouped By Fields|type=enum|enumValues=all,name&product

#if($paramGroupByField == "all")
   #set($PeriodQueryString=" enum option = $paramGroupByField")
#elseif($paramGroupByField == "name&product")
   #set($PeriodQueryString=" enum option = $paramGroupByField")
#end

Parameter $PeriodQueryString

 

Can you please let me know what could be the reason for such a changed behavior?

 

Thank you

 

with warm regards

ramki

 

 

2 answers

1 accepted

0 votes
Answer accepted
Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2021

@Alexis Robert Thank you again, I tried escaping it did not work.

I continued my attempts. This worked when I changed the line

from 

#elseif($paramGroupByField == "name&product")

to

#elseif($paramGroupByField.replace("&", "&") == "name&product")

 added .replace("&", "&") to the user input parameter variable.

not sure about the any other impact, atleast I can get my macros work I think.

0 votes
Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

Hi @Ramakrishnan Srinivasan ,

 

there could be a few reasons why your user macro stopped working.

First, to investigate this kind of issue you should start Confluence in Safe Mode and check if the problem is still present. 

Then I would activate one by one the addons, because there might be a conflict with a specific new version that prevents your user macro from working.

 

Let me know if this helps, 

 

--Alexis

Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2021

Hi @Alexis Robert Thank you for the response. I will try that in my staging setup, but do you think that the problem not recognizing enumValue option with "&" can arise from other add-ons. My knowledge here is limited so please bear with me for this very basic question.

Also, I found that if I change the option from "name&product" to "name-product", the macro starts working. So, I think somewhere "&" symbol in velocity template lost its characteristic.

Alexis Robert
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 7, 2021

There might be a change in how Confluence handles special characters, it's hard to say since a lot of stuff is updated between two releases, even internal components can have an impact on this kind of stuff.

In your case it might be just this : an update somewhere that prevents using special characters, so maybe switching from "&" to "-" is the solution here !

Maybe you can try esacaping the character, like this : "\&" ?

Suggest an answer

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

Atlassian Community Events