Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

My template variable in a custom JQL user macro does not render more than once, why not?


I created the following user macro based on an excellent post in the community which allowed me to inject a "$pagecreationdate" variable into a JQL query wrapped inside of a custom user macro container.  This proof of concept allows me to pull in a list of Jira issues which were in a specific status between "$pagecreationdate 07:00" and "$pagecreationdate 15:30", as an example.

My goal is to create a template using several of these custom macros, each responsible for generating a static list of Jira issues.  This worked great for the first JQL query I entered into the $body of my user macro.  However, when I added a second instance of the same macro along with a slightly different JQL query, I noticed the second template variable simply does not render the value that gets entered by the user.

Here is my user macro:

## This macro will not accept any parameters. It will simply be used as a container for accepting JQL queries with template variables.
## @noparams

#set ($body = $body.replaceAll("\Q<p>\E",""))
#set ($body = $body.replaceAll("\Q</p>\E",""))
#set ($body = $body.replaceAll("\Q<span>\E",""))
#set ($body = $body.replaceAll("\Q</span>\E",""))
#set ($body = $body.trim())

<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">JIRA</ac:parameter>
<ac:parameter ac:name="columnIds">issuekey,summary,issuetype,created,updated,duedate,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="maximumIssues">50</ac:parameter>
<ac:parameter ac:name="jqlQuery">$body</ac:parameter>
<ac:parameter ac:name="serverId">MY-SERVER-ID</ac:parameter>

With this user macro, I create a simple template page with a variable named $pagecreationdate.  My expectation is the user is prompted to enter $pagecreationdate just once when they instantiate the page.  Within the container of my user macro, I have a JQL query as follows:

project = MYPROJECT AND status WAS IN ("In Progress", "Resolved") BEFORE "$pagecreationdate 07:00"

In the first container, $pagecreationdate renders just fine.  If I add a second user macro either via copy/paste or by instantiating a net-new macro, the $pagecreationdate template variable will not render within the user macro container.  Outside of the macro, the variable will render as many times as I need it to.  It's only within the macro this becomes an issue.

If anyone can help clue me in on what's going on, it would be extremely helpful.  I suspect I can simply create multiple user macros, call them different names and solve my problem this way.  However, I'd be really surprised if I'm not able to re-use this code.

I can provide screenshots if you want to see exactly what this looks like.  Essentially, from a user perspective, they access the Confluence page and are met with a "Create From Template" button.  They click the button, it calls my template, prompts them to enter a date for $pagecreationdate and brings them to the page, preferably with the JQL queries rendered and ready to go.

1 answer

0 votes
Fabian Lim Community Leader Jan 15, 2022

Hi @Christopher Parsons

Can you please share the screenshots to have a full context of your issue?


Hi @Fabian Lim ,


Thank you for the response.  After some further debugging, we were actually able to get this figured out.  It seems a copy and paste of the previous JQL might be introducing either some hidden characters or maybe a different type of text encoding that the macro did not like 


We learned typing the JQL query again from scratch seems to have fixed the issue despite the text looking identical in the GUI.


I am not at my computer currently but I will update this post later with some screenshots in case it's helpful to others in the community.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

42,556 views 29 133
Read article

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