Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Getting value of a single custom field using REST API

I'm trying to create a script to run as as post-function and I'm a bit fuzzy on the Jira Cloud REST API.  Is there something that exists in the API that allows me to get the value of an issue's custom field?

I know the custom field ID, and Scriptrunner has as its context, the issue ID (I believe).  I just need to find how to extract the value for specific custom fields.

Thanks in advance!

3 answers

1 accepted

0 votes
Answer accepted
Prince Nyeche Community Leader Apr 27, 2021

@Robert Wen 

Try the below code to get the field value

def key = issue.key

def field = issue.fields

def cfINeed = "customfield_12853"

// hold field value
def my_value

def result = get("/rest/api/2/issue/${key}")
.header('Content-Type', 'application/json')

if (result.status < 300) {"Success getting fields")
// field value
my_value = field[cfINeed]
} else {"Error getting fields")

I think I'm close.  I looked at and it showed me how to specify the fields I want using queryString.

The static analyzer doesn't like the "value" in each statement for the fields.  Anyone have any experience with the call?

Hi Robert,

I can confirm that we have examples of how to extract values from different types of fields in the documentation page located here and you can run these examples on the Script Console page in order to see how to extract values from different type of fields.

You will be able to use these examples as a reference guide in order to help you to create the script that you require.

As a tip for the future, I can confirm the best way to see what structure a field uses is to set a value in the field on a test issue and then to run the Get Issue Fields example script on the Script Console as this will return the JSON structure for the issue and show how the data is stored for the field and you can use this to help see what structure you must specify to extract the value from a field on an issue.

I hope this information helps.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

856 views 30 33
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