Script Runner create a subtask post function condition problem

Trying  to create a sub-task based on a checklist field.

I have the following condition:  cfValues['myfield']*.value.contains("myValue")

Returning the following error:  ERROR - No such property: cfValues for class: Script1

The static checker returns this:  The variable cfvalues is undeclared.

This worked on a server version I was previously using, but not on my current cloud version.

Did I do something wrong?


2 answers

1 accepted

3 votes
Accepted answer

Hi Alan,

There are significant differences between the Cloud and the Server versions of JIRA and how ScriptRunner works on the two platforms. You can read more here and here

For this particular question, the equivalent condition will look something like this:

// Get the field ids
def fields = get('/rest/api/2/field')
        .body as List<Map>

def myFieldId = fields.find { == "myfield" }.id
return issue.fields[myFieldId]?*.value.contains('myValue')

Hope that helps,


Hey Jon....sorry for the delay.

Using that script gives me the following error

2017-02-06 22:40:19,707 ERROR - Class:, Config: [, uuid:2a268983-c96a-4f4f-a42f-3e04804d17db, description:BitBucket Request, condition:// Get the field ids
def fields = get('/rest/api/2/field')
return issue.fields[myFieldId]?*.value.contains('bitbucket'), summary:New BitBucket Access Request!, issueTypeId:10202, executionUser:INITIATING_USER, additionalCode:]

Any thoughts on this?

Hi Alan,

Looks like I got my Groovy slightly wrong - it should be:

return issue.fields[myFieldId]*.value?.contains('myValue')

Thanks, Jon

Hey Jon:

Using this gives me a new error below:

groovy.lang.MissingPropertyException: No such property: issue for class: Script1 at at at Source)

Static checker says:  "The variable 'issue' is undeclared" at line 8 column 8.

Thanks a lot for your time and help with this!


Hi Alan, are you running that from the Script Console or have you set it as the condition on a post function?

It won't work in the Script Console as the code expects there to already be an issue in the execution context...

Hey Jon:  I did run it from the console, however the static checker from the condition dialogue box is still saying "The variable 'issue' is undeclared" at line 8 column 8

I'll try to execute the post function anyways to see if it goes through.

Hi Alan, there are a couple of problems with the static type checking that we're close to having a fix for, so sometimes the messages are misleading. Did this code work in the post function?

Hello @Jon Bevan [Adaptavist] ,


I also have the same requirement, the above code is not working for us. Can you please help here?  I see the errors below : 






Hi Swathi,

Those particular "errors" are actually just limitations of our type-checking system.

You can just ignore them, or make them go away by using the following code:

List<Map<String, Object>> fields = get("/rest/api/2/field")
String myFieldId = fields.find { == "myfield" }.id

return (issue.fields[myFieldId] as List<Map>)*.value?.contains('myValue')


Hi @Jon Bevan [Adaptavist] ,


Thanks so much it worked for a checklist custom field. 

I am trying the similar code on a single select list field "Department" but it is failing , can you tell me what Am I doing wrong?

def customFields = get("/rest/api/2/field")
.findAll { (it as Map).custom } as List<Map>

def input1CfId = customFields.find { == 'Department' }?.id
def input1 = issue.fields[input1CfId] as String
if (input1 == 'Operations & Maintenance')


When I run this , I expected a sub task to be created. I see that the run is successful with message the following message : 

2018-02-16 12:55:20.267 INFO - Serializing object into 'interface java.util.List'
2018-02-16 12:55:20.290 INFO - GET /rest/api/2/field asObject Request Duration: 555ms
2018-02-16 12:55:20.328 INFO - Condition didn't eval to true, exiting

Can you tell me why it din't create a sub task? Appreciate your help here. 




Hi Swathi,

I think you need to use:

def input1 = issue.fields[input1CfId].value as String


Hi @Jon Bevan [Adaptavist] ,


Appending value also dint help . However, when I tried some script in console i see that I am able to fetch the value... 

def issueKey = 'HR-39'

def result = get('/rest/api/2/issue/' + issueKey)
        .header('Content-Type', 'application/json')
if (result.status == 200){
    return result.body.fields.customfield_10088.value
else {

    return "Failed to find issue: Status: ${result.status} ${result.body}"


Same script is not working when I place in post function. Can you help me in converting the above code to work in post function? 




Hi @Swathi Komirelli [Appfire]

The script will fail if there is no value in that field, so you'll need to use the safe navigation operator:

def input1 = issue.fields[input1CfId]?.value as String

If that doesn't resolve the problem then I'll need to see the specific error messages you're seeing.


PS - I have verified that the field that I am using DOES exist, and I have done a re-index for good measure.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,178 views 5 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you