Scriptrunner for Confluence - Custom Macro to pull in Custom Jira Fields

Tracy Langston x2472 December 27, 2024

I am trying to create a Macro to prompt user for a Jira#, and then pull in specific custom fields to display in confluence.  I found this 

 

Example: Get Jira Issue Information on a Confluence Page

I successfully created the Macro based off your example, I am not able to figure out how to get one of our Custom Jira fields added, I get 'null' results back every time.    Are there any examples of how to pull in a custom jira field?  

2 answers

2 accepted

0 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 30, 2024

Hi Tracy,

I can confirm in the example above the issue variable returns all fields on an issue so you can access custom fields using the customfieldId e.g like

${issue.fields.customfield_10010}

where customfield_10010 is the ID of the custom field you wish to return the value back from on the issue.

I have tested this using the text variable like below to show the value of a custom single select list field and a custom single line text field and can confirm this works as shown in the screenshot below.

 

String text = "<H1>project name "+issue.fields.project.name+"</H1><br>" +
"<H3>issue ID ${issue.key} </H3> <br>" +
"<H3>issue Summary : ${issue.fields.summary} </H3>" +
"<H3>Multi select custom field value : ${issue.fields.customfield_10073.value} </H3>" +
"<H3>Single Line text custom field value : ${issue.fields.customfield_10082} </H3>"

 

Screenshot 2024-12-30 at 13.06.59.png

Please note you will need to change the properties you access on different field types based on the field type and the best way I can advise to see what properties exist on a field is to run the Get Issue Fields example script on the Script Console page in Jira to see how data is stored on fields for an issue.

I hope this information helps.

Regards,

Kristian

Tracy Langston x2472 December 30, 2024

Thank You so much for your assistance!

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 2, 2025

Hi Tracy,

You are welcome.

If this answer solved your issue, could you please mark it as accepted to show it has correct for other users searching for the same question.

Regards,

Kristian 

0 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 27, 2024

Hello @Tracy Langston x2472 

What is the custom field type of the field you are trying to access?

Show us each of the methods you have tried to include the field in the output.

Tracy Langston x2472 December 30, 2024

I got most of what I needed from Kristian's examples above, but still needing to know how to pull in custom field that is a 'User Picker' field.   Could you help me with that?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 30, 2024

Have you tried the method recommended by Kristian to get the data?

Tracy Langston x2472 December 30, 2024

Disregard that last question Trudy.  I found it :-)

"Project Manager: ${issue.fields.customfield_10037.displayName}"
Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events