Behaviour script for updating customfield not working

I'm trying to set a custom field list value based on another custom field's value.

In other words, if field1(label) has some labels added to it, set field2's(select list) value to "YES"

Here is my code that throws an exception:

def field1 = issueToUpdate?.getCustomFieldValue(customField1) // field1 is a list object

FieldConfig fieldConfig = customField2.getRelevantConfig(underlyingIssue)

def option = optionsManager.getOptions(fieldConfig).find {it.toString() == "YES"}

FormField field2 = getFieldByName("custom_Field_2")

if (  field1 != null ) {

   log.debug("field1 not empty, updating issue");


    log.debug("updated issue");




In the log:

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null


        at Method)

        at org.codehaus.groovy.reflection.CachedClass$3.initValue(

        at org.codehaus.groovy.reflection.CachedClass$3.initValue(


        at groovy.json.JsonOutput.getObjectProperties(

        at groovy.json.JsonOutput.writeObject(

        at groovy.json.JsonOutput.writeMap(

        at groovy.json.JsonOutput.writeObject(

        at groovy.json.JsonOutput.writeArray(

        at groovy.json.JsonOutput.writeObject(


 Please suggest other ways to set the custom field value

1 answer

1 accepted

1 vote

The problem is you are setting the form value to an Option object, then getting a SO when we try to serialise that. (Which could probably be handled better on our side).

You need to set the form value to the option ID (I think, or the value - probably the ID):


That worked, thanks Jamie.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

772 views 3 11
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