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

How can I change the output of a confluence user macro to be an Integer?

I need to change the output of a user macro to be an Integer or String depending on use. How can I set the output to be "86" instead of an "86 issues" link to jira. Created the user macro linked below in article. Edited macro to output just have count of issues as a jira link. Any direction on how to display results of JQL query as string in confluence would be great.

https://community.atlassian.com/t5/Confluence-questions/Using-template-variables-as-input-parameters-to-jira-gadget/qaq-p/189292

1 answer

Hi Eric,

Two things worth mentioning:

  • You can't change the output type of macros. Macros always return a String. Of course the String could contain only a number but if we're talking about data types it is still a String.
  • The examples you linked to use Confluence default macros such as "jira" or "jiraissues". Therefore you don't really have control over their output.

I see a few possible solutions to your problem here:

  • You could build your own user macro that doesn't rely on a Confluence default macro and instead makes the request itself. (Could be quite complex and requires good user macro programming knowledge on your part)
  • You could include some JavaScript in your user macro that removes the " issues" part from your result so only the numbers stays. (Probably way simpler, but very janky and generally not advisable)
  • You could use a third party solution like our app PocketQuery. In PocketQuery you could simply set up a JQL REST query that fetches your data. You can then write a velocity template for it that defines how the data should be rendered. In your case this should be very simple. And since you're already building complex user macros to begin with you might find that PocketQuery will make your life a lot easier in many other situations where you want to show data from external sources as well. If you want to give it a shot and have any questions you can always ask our support. We're happy to help! :)

Best regards,
Sven

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

32 views 2 4
Join discussion

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