Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I am trying to setup a listener using Script Runner to auto transition a field based on the value of a custom field. The plugin provides the following template:
cfValues['SomeCustomField'] == 'Some Value'
I have tried the following:
cfValues['Field Name'] == 'Yes'
But this isn't working. Any suggestions on how to check the value of a custom field for my condition statement?
Turns out i was making a noobish mistake. This worked for me:
cfValues['Standard Request']?.getValue() == 'Yes'
I needed to add the getValue method in order to do my comparison.
The key question as Thomas says is "what kind of field". You can do
log.warn cfValues['Standard Request']
That will give you the class name, from that you can read the javadoc to see how to get the string value or values, or whatever.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is not working for me when using Select List, as opposed to Radio Buttons. Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you post what you are using.
cfValues[
'A Radio Field'
]?.getValue() ==
'Yes'
should work fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using:
cfValues[‘A Select List Field’]?.getValue() == ‘Yes’
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any ideas why this wouldn't work for a select list?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should work fine. Use an assertion to test as per https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-PowerAssertions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I guess 'Yes' needed to be written "Yes" or the condition kept failing.
I got this working after reviewing your link. Thanks so much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there a parameter I can add to make the condition specific to a project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
&& issue.projectObject.key == "ABC"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can't seem to get this to work. Tried using an assertion and it returns 404 page
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
issue.projectObject.key != "ABC" && cfValues['Customization Issue']?.getValue() == "Yes"
This script accomplishes what I want it to do when the value = Yes. But, when the custom field = No, it also firing the function, when I don't want it to.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nevermind. Got it figured out thanks to this thread: https://answers.atlassian.com/questions/70196/how-to-set-complex-validators-in-jira-s-workflow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What kind of custom field is this?
If it is a checkbox you could use:
cfValues['Field Name'] != null
Hope this helps,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a radio button with "Yes" or "No" as options.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Answer o Yes o No ............. it was an example of the radio button field I have with the values which can be chosen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, but how do you get the value ? cfValue['Answer'].value ?
Answer o Yes o No
Because, in Jira, I would like then test cfValue['Answer'].value == 'Yes' in order to fasttrack a transition, but it does not work unfortunately...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should be cfValues (plural)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use: cfValue['Answer']?.value
Use Admin -> Built-in Scripts -> Condition Tester to make sure that is evaluating to what you expect...
> Ok, but how do you get the value ? cfValue['Answer'].value ?
> Answer o Yes o No
I didn't understand this...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you get an answer for radio button ? I'm still looking for...
Thanks,
Any help appreciated
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The accepted answer is correct for radio buttons.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.