You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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?
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")
}
Regards,
Adrien
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How do we check if the given field value is text or not in behaviour script in jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.