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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I check in a behaviour script that the "Affects version/s" field is empty? Edited

I have an "Affects Branch/es" custom field, and I'd like to force to have only one of "Affects version/s" and "Affects Branch/es" filled - in our system filling none or both is invalid.

A tried the following code, but it does not work:

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

@BaseScript FieldBehaviours fieldBehaviours

def branchesField = getFieldByName("Affects Branch/es")
def branchesFieldStringValue = branchesField.getValue()

def versionsField = getFieldById("versions")
def versionsFieldStringValue = versionsField.getValue()

if (branchesFieldStringValue == null && versionsFieldStringValue == null) {
branchesField.setError("brancherror both empty 3")

if (branchesFieldStringValue != null && versionsFieldStringValue != null) {
branchesField.setError("brancherror both filled 4")

I think the problem is the way I checked if they're empty or not. I tried with converting them with .tostring() and comparing with "" and some other ways - but now I think I'm getting lost. Can someone help me?

1 answer

1 accepted

1 vote
Answer accepted

Hello @Gergely Fehér


This is a Groovy script. Groovy is made to simplify this kind of things.

Try this:

if (branchesFieldStringValue && versionsFieldStringValue) {
branchesField.setError("branchesboth empty 3")

if (!branchesFieldStringValue && !versionsFieldStringValue) {
branchesField.setError("brancherror both filled 4")




Hi @SITTER_Adrien,

Thanks a lot, it works!

I wrote the below code in behaviour script to check if the field is empty . It is working if it is empty.. however, If i enter something the error is not cleared. Please help ,

I need to clear the error message if there is something in the field.

def loc=getFieldById("customfield_10612")
if (loc) {
loc.setError("Please Enter loc")

How do we check if the given field value is text or not in behaviour script in jira

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you