Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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?



0 votes
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.
Apr 24, 2019 • edited

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
AUG Leaders

Atlassian Community Events