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

Custom field condition with Scriptrunner cloud

I'd like to set a condition for a fast-track script based on the value of a custom field. I used to have this working in Scriptrunner (Server) but cannot find an example of how to work it using Scriptrunner (Cloud).

My successful old implementation was:

cfValues['Change Category']?.value == 'Fast Track'

All research done so far indicates I need to hard code the custom field ID to be something like (?!):

issueInput.fields.customfield_10107 == [value: '{{Fast Track}}'] as Map

where 10107 is the custom field ID. Which is not ideal as I'd like to refer to the name instead.

Any ideas?

2 answers

I created this script and used it as condition in post function

//This script is for Scriptrunner Jira Cloud to get custom field value of current issue as condition in postfunction


//define custom field ID from the field where you want to get the value of
def customFieldName = 'customfield_10046'

//create API request to get custom field value
def result = get("/rest/api/2/issue/${issue.key}?fields=${customFieldName}")
.header('Content-Type', 'application/json')
if (result.status == 200) {
result.body.fields[customFieldName].value.toString() == "YOUR_CONDITION"
//if you need to check if the field value machtes YOUR_CONDITION and a assingee is set
//result.body.fields[customFieldName].value.toString() == "YOUR_CONDITION" && issue.fields.assignee != null
} else {
return "Error retrieving issue ${result}"


Thanks for sharing your script! I tried it and it works, despite getting a warning "[Static type checking] - No such property: value for class: java.lang.Object @ line 12, column 5." for 

result.body.fields[customFieldName].value.toString() == "YOUR_CONDITION"


Did you encounter this? How can this be rectified?



Hi Tim,

Thank you for your question.

I can confirm that by default ScriptRunner for Jira Cloud will require you to specify setting the field by its ID due to the fact the Rest API in Jira cloud is required to specify fields by their ID's and the name cannot be used as Jira Cloud does not have a Java API like the server version does.

You can see more details on the differences between the cloud and server versions of the plugin in the documentation page here.

I can confirm that if you wanted to dynamically look up the ID of the field base on its name then you can do this by making a call to the field rest API to return the field based on its name.

I can confirm that we have an example of how to do this inside of the documentation page here where the customField rest call returns the field based on its name so that the field can be specified by its ID.  You will be able to use this example as a reference to show how you can look up fields based on their name.

If this response has answered your question can you please mark it as accepted so that other users can see it is correct when searching for similar answers.



Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

101 views 0 6
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