Missed Team ’24? Catch up on announcements here.

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

ScriptRunner behaviour based on Xray custom field

Venkat_S July 21, 2021


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

Suggest an answer

Log in or Sign up to answer
0 votes
Putri Nur Dayana Kamarudin [Adaptavist]
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2021

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
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 21, 2021

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)

AUG Leaders

Atlassian Community Events