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
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

161 views 0 4
Join discussion

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