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

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

ScriptRunner behaviour based on Xray custom field

Hi,

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.

ntgsui_scriptrunner.png

 

Any help here is highly appreciated.

 

Thanks in advance,

Venkat

2 answers

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>
rawValue=$rawValue(${rawValue.getClass()})<br>
formValue =$formValue (${formValue .getClass()})<br>
"""
xrayFld.setHelpText(helpText)

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)

requiredFieldNames.each{fieldName->
getFieldByName(fieldName).setRequired(required)
}

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
}

result 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center Apps Program coming soon

G’day Bamboo customers, As we approach GA for Bamboo Data Center , we would like to inform you that the Data Center Apps Program for Bamboo starts this quarter. How long does it take? We are g...

67 views 0 6
Read article

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