Hello colleagues,
There is a behavior to restrict a select list options, that works on Jira 7 but doesn't on Jira 9 (the 7's clone).
The type checking is passed, the error message is:
Cannot invoke method getRelevantConfig() on null object
Googled reasons point to an issue with a field context, but there is the global context.
Can you please advise.
BR,
Ivan
Hi @Ivan D
Could you please provide more information on how you are running the test, i.e. when are you trying to trigger the Behaviour? Is it on the Create, Edit or Transition screen?
Please clarify what version of ScriptRunner you are currently using.
Also, it would be beneficial if you could share a screenshot of your Behaviour configuration.
Thank you and Kind regards,
Ram
Hi Ram,
Is it on the Create, Edit or Transition screen?
On Edit. But getActionName() isn't used.
what version of ScriptRunner
share a screenshot of your Behaviour configuration
BR,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ivan D
The current code that you are using is applicable for Jira 7. However, from Jira 8 onwards, it will not work as expected.
Since you intend to filter the options from the Select List, I suggest you change your approach to:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleList = getFieldByName('Sample List')
def listOptions = []
if (underlyingIssue && actionName == 'null') {
listOptions = ['CEO','COO', 'CTO']
sampleList.setFieldOptions(listOptions)
}
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Behaviour configuration:-
From the screenshot of the code you shared in your last comment, I will assume that this Behaviour is configured using the Behaviour Initialiser since no condition is set to determine the filtration.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
Thanks a lot!
Actually it was necessary to tune here, besides obvious settings, also
getFieldByName
It was because first I've got the same error message again. It pushed me to the idea that for some reason the script cannot find a context of the Status field by name, so I've tried
getFieldById("customfield_11129")
and it helped.
Also if() part prevented working (is it needed?) so I removed it. The final view is:
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
//def sampleList = getFieldByName("Status")
def sampleList = getFieldById("customfield_11129") //Status
def listOptions = []
//if (underlyingIssue && actionName == 'null') {
listOptions = ['Активный','Не активный']
sampleList.setFieldOptions(listOptions)
//}
The funny side effect is that with the change of ByName to ById the old script started working too)
BR,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.