ScriptRunner Behaviour, automatically update field value based on another custom field

During issue creation, we make a custom field required, Regression Issue, in our JIRA workflow.  It's only required during creation.  We wanted to only force the requirement on new issues, not force all the previously created issues to update this field during edit.  Currently, we have a ScriptRunner Behaviors script to make other custom fields visible and/or required when certain values are select in the "Regression Issue" field. 

The problem arises with our SalesForce integration.  When users create new issues using the remote API.  The Regression Issue field doesn't register as required custom field. 

As a workaround, I was hoping to take advantage of the Behaviour script again to recognize a specific custom field, SalesForce ID, that's set during creation.  If a value is added (any value), then set "Regression Issue" select list to "No".  However, I can't seem to get this to happen.  I've also tried using certain user group as a criteria, but that's a no go too.

Is it possible to automatically force a field value change based on another field not being empty?  I've included my current Behavior script.


import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def regressionIssueField = getFieldById(getFieldChanged())
def regressedVersionField = getFieldByName("Regressed from Version(s)")
def regressedBuildField = getFieldByName("Regressed from Build #")
def salesforceField = getFieldById(getFieldChanged())

String regressionIssueValue = regressionIssueField.getValue()
String salesforceValue = salesforceField.getValue()

if (salesforceValue) {

if (regressionIssueValue == "Yes") {
} else {


Thanks, Chuck

1 answer

2 votes

Unfortunately if your creating the issue through the REST API the behaviours are not applied. That is one of the limitations of behaviours explained here.

Your probably best off using a validator to make the field required which will still be applied when creating the issue via the REST API. If you want further customisation over the requiredness of the field you should consider writing a scripted validator.

OK.  I suspected that might be the case.  Thanks for confirming! 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,766 views 18 21
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