Create
cancel
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

User macro - extract a number from space key and use that as date range for JQL?

Hey guys,

I'm currently seeking help in a challenging task (at least for me) ;)

We have a Confluence space, that gets copied every year and where the copied space is then modified. These particular spaces also have the current year in its space keys, i.e. "wbk2022" for the new one, the one from last year would be "wbk2021". All pages in these spaces also include a user macro, that grab all relevant Jira issues, which relate to that space and where created that particular year.

Here's an example:
<ac:parameter ac:name="jqlQuery">project = WEITERBILD and "Titel des Training" ~ "$content.title" AND created >= 2021-01-01 AND created <= 2021-12-31</ac:parameter>

What we have to do every year, is copy that space with all its pages, create a copy of last years user macro and alter the date in that query. This is needed, because the "old" spaces need to be archived along with all referenced Jira issues of the corresponding year.

What I am trying right now is to extract the year from space key and use that information in my JQL query, therefore we would not need to create another user macro every year or alter all pages in the newly copied spaces.

I hope I was clear enough about my idea. Any help is highly appreciated ;)

Thanks and best regards
Sascha

1 answer

0 votes
Bill Bailey Community Leader Jan 06, 2022

Would something like this work?

#set($dateInfo=$action.dateFormatter.formatGivenString("yyyy", $space.creationDate))

Thanks for your suggestion, I got it to work as I wanted in the first place, I just had a typo in my code... :(

I finally managed to extract the year from space key with a split() function, set my date range variables for the following JQL query and used these in my JQL:

<ac:parameter ac:name="jqlQuery">project = WEITERBILD and "Titel des Training" ~ "$content.title" AND created >= $start AND created <= $end</ac:parameter>

Like Dominic Lagger likes this

Suggest an answer

Log in or Sign up to answer
TAGS
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 ...

1,060 views 8 43
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