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

Getting value of a single custom field using REST API

Robert Wen Community Leader Apr 26, 2021

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

@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")

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.



0 votes
Robert Wen Community Leader Apr 26, 2021

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?

Suggest an answer

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

Next level incident management in Jira Service Management

Hello Atlassian Community! We’re thrilled to announce some exciting changes to incident management in Jira Service Management Cloud, in order to give your teams extra muscle during incidents, and ...

1,490 views 20 12
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