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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner behaviour based on Xray custom field


I need suggestions for a ScriptRunner behaviour for the below condition which is based on the value of Xray "Test Repository Path"


WHEN the "Test Repository Path" is "NTG7 Widgets"

THEN the custom fields "Review" and "Review Comments" should be made mandatory.



Any help here is highly appreciated.


Thanks in advance,


2 answers

Hi there!

This is currently not possible via Behaviours, however, you can do this via a Simple Scripted Validator.

You can alter the following code to your requirements and add it to your validator.

def testRepo = cfValues["Test Repository Path"]
def textbox = cfValues["textbox"]

def result = false as Boolean

if(testRepo == "test 1") {
  if(textbox == null) {
      result = false
  } else {
      result = true
} else {
    result = true

0 votes

I don't have Xray so I can test and figure this out myself, but maybe I can give you some strategies for figuring it out yourself.

The critical thing you need to find out is if behaviour is even able to detect changes to Xray custom fields and getting the data.

So, create a behaviour configuration with the correct mapping and add your Xray field.

Then add a server-side script on that Xray field.

Add a short script to pull out the data from the custom field and display it on your form:

def xrayFld = getFieldById(fieldChanged)
def value = xrayFld.value
def rawValue = xrayFld.value
def formValue = xrayFld.formValue

def helpText = """value=$value (${value.getClass()})<br>
formValue =$formValue (${formValue .getClass()})<br>

If xray fields are supported by behaviour, you should see some red text below the field that will update each time you change the value in field.

If any of these values contain anything that looks like "NTG7 Widgets", then you should be able to detect that value and conditionally make the other 2 fields required or not.

For example, if the result of 'value' looks like "NTG7 Widgets (String)" then you could try a script like this:

def xrayFld = getFieldById(fieldChanged)

def requiredFieldNames = ['Review', 'Review Comments']

def required = (xrarFld.value == 'NTG Witdget)


Suggest an answer

Log in or Sign up to answer

Atlassian Community Events