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.
#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">
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 " 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.
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.
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 ...
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