• Community
  • Products
  • Jira
  • Jira Core
  • Questions
  • /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.behaviours.BehaviourManagerImpl] Script function failed on issue:

/rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.behaviours.BehaviourManagerImpl] Script function failed on issue:

2016-03-31 10:08:41,492 http-bio-8080-exec-92409 ERROR aa017659 608x22150305x3 178cxf1 10.184.177.58,10.160.5.7 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.behaviours.BehaviourManagerImpl] Script function failed on issue: (create issue) project/issuetype: FACSUP/Privilege Requests, user: aa017659, fieldId: customfield_15620, file: <inline script> java.lang.NullPointerException: Cannot invoke method contains() on null object at java_lang_String$contains$6.call(Unknown Source) at Script1.run(Script1.groovy:6)



Behaviours code


 

def blockedCf = getFieldByName("Factory Tool")
def reasonCf = getFieldByName("Pipeline")
if (blockedCf.value.contains("Feature Tracker")) {
   reasonCf.setRequired(true)
} else {
   reasonCf.setRequired(false)
}

3 answers

Factory Tool is a checkbox field that is required

It appears to be throwning the errors when the user selects the option Feature Tracker which requires Pipeline by the script and the unselects Feature Tracker when makes Pipeline unrequired.

Hi Kevin,

I have updated my example script above so that it now shows how to make a field required when a check-box is set to certain value.

This script was developed using JIRA 7.1.0 and ScriptRunner version 4.2.06.

I hope this helps.

Thanks

Kristian

 

Behaviors plugin still throws the an error when unselecting the field that is makes the other field required

Can you please confirm what version of ScriptRunner  and JIRA you are using as well attach a screenshot of how you can configured my code above.

I have tested this on my instance and get no error thrown on my system. Also can you confirm if any of the fields referenced in this behaviour are used by any other behaviours or scripts as these could be the cause.

Also could you please post a screenshot of the error being displayed.

Once we have this information then we will be able to look to help you further.

Thanks

Kristian

 

JIRA 6.3.12

SR 3.0.16

Can you please provide all of the other details requested as well as at the moment we are unable to replicate your issue.

Thanks

Kristian

behaviour config.JPG

Could you please try using my modified code above which I have incuded below as this is the correct syntax for checking check-box values inside of Behaviours.

// get a pointer to my checkbox field
def blockedCf = getFieldByName("Factory Tool")
 
// Get the blockedCf value as a string
String blockedCfValue = blockedCf.getValue()
 
// Get a pointer to my reason select list field
def reasonCf = getFieldByName("Pipeline")
 
// If the  Factory Feature Tracker option is checked make the pipeline field required
if (blockedCfValue == "Feature Tracker") {
    reasonCf.setRequired(true)
} else {
    reasonCf.setRequired(false)
}

If using this code you still get the error can you please post a screenshot of where the error is displayed along with an extract of the atlassian-jira.log file from when the behaviour is executed.

Thanks

Kristian

I have tested the code above using JIRA 6.3.5 and ScriptRunner 3.0.16 and confirm that it works as expected. If further assistance is needed please provide screenshots of the error as well as an extract of the atlassian-jira.log file.

Thanks

Kristian

It works but the only issue I see is that is there are 2 checkboxes selected for Factory Tool the Pipeline field i not required.

Hi Kevin,

Yes with Checkboxes you can select more than one and the Pipeline field will only be made required when just the feature tracker option is selected.

You will either need to change the field to be a Single Select List if you wish to only make the pipeline field required when Factory Tool is selected or you will need to add extra if statements for each combination of options that could contain the Feature Tracker option checked.

I hope this helps.

Kristian

Hi Kevin,

I am assuming that the field you are checking the value of is a checkbox field and so have enclosed a sample script of how you make a field required based on the value of a select list based on your example above. This behaviour should be configured on the blockedCf field.

// get a pointer to my checkbox field
def blockedCf = getFieldByName("Factory Tool")

// Get the blockedCf value as a string
String blockedCfValue = blockedCf.getValue()

// Get a pointer to my reason select list field
def reasonCf = getFieldByName("Pipeline")

// If the  Factory Feature Tracker option is checked make the pipeline field required
if (blockedCfValue == "Feature Tracker") {
    reasonCf.setRequired(true)
} else {
    reasonCf.setRequired(false)
}

I hope this helps

Kristian

Issue was resolved with the following

 

// get a pointer to my checkbox field
def blockedCf = getFieldByName("Factory Tool")
  
// Get the blockedCf value as a string
String blockedCfValue = blockedCf.getValue()
  
// Get a pointer to my reason select list field
def reasonCf = getFieldByName("Pipeline")
  
// If the  Factory Feature Tracker option is checked make the pipeline field required
if (blockedCf?.value?.contains("Feature Tracker")) {
    reasonCf.setRequired(true)
} else {
    reasonCf.setRequired(false)
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

254 views 2 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you