Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

script runner validator- reject the option for setting FieldA as long as the fieldB is empty

Deleted user March 14, 2018

 I would like to reject the option for setting the FieldA ("Fixed in version/s") filed as long as the fieldB ("Affects Version/s") field is empty

should I work with :

if (! cfValues['FieldA']) ...

how should I write it with script validator? 

 

Thanks for your help !

1 answer

1 accepted

0 votes
Answer accepted
Knut Arne Ristebråten
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 14, 2018

Hi,

We have been able to solve similar situation to this (though customFields) by adding a script to a Scriptrunner Behaviour. Add the script to the field you want to monitor for change (in your case, add it to fieldB). Don't set any behaviour on the fieldB - the script will handle the behaviour for your fieldA

I haven't configured it by checking if is empty, just to specific values - but you probably are able to adapt it to your needs.

Remember to change "customfield_10000" with correct field-ID.
Remember to change "fieldBValue == "Yes"" to suit your needs.

The Code:

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

def fieldBField = getFieldById(getFieldChanged())
def fieldAField = getFieldById("customfield_10000")

String fieldBValue = fieldBField.getValue()

if (fieldBValue == "Yes") {
fieldAField.setReadOnly(true)
} else {
fieldAField.setReadOnly(false)
}

 Hope this helps.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events