Could you please specify what version of Jira you are currently testing on?
Also if you could share a screenshot on how you are using cfValues it would be beneficial.
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.
From the code you shared, it appears that you are using this for a Simple Scripted Validator. Please confirm.
After reviewing the code you shared, you don't need to use any if/else statements.
Could you please try to modify your validation code to just:-
(issue.issueType.name == 'Save' && cfValues['Save - Root cause']) || cfValues['Root cause']
and see how it goes?
I am looking forward to your feedback.
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.
Yes in this case for a simple validator, still the same problem.
If I add a log it also returns no value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please modify your code according to the example below:-
(issue.issueType.name == 'Story' && cfValues['List2']?.value == 'Option1') || cfValues['List2']?.value == 'Option2'
Please note that the working sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Simple Scripted Validator configuration:-
In the example above, if the issue type is Story and the List2 value is Option1, or if any issue type is selected and the List2 value is Option2, the validation will pass else; the validation error will be thrown.
I hope this help 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, I don't want to check for a specific option in this case but any option, in any case I tested it but still the same issue. None of the cfvalues return anything so any check I do always returns false.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to check on any value except for the None option, you need to update the validator condition to:-
(issue.issueType.name == 'Story' && cfValues['List2']?.value.toString() != 'null') || cfValues['List2']?.value.toString() == 'null'
I hope this helps to answer 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,
Maybe my explanation isn't clear enough. But the issue isn't the code, as it works just fine in production on the older version of scriptrunner.
But whatever code I use it isn't reading the value or input of the field defined via cfValues.
If I log in prod and test environment:
log.warn(cfValues['Root cause']?.value.toString())
I get back 'null' in test and 'Accessibility' the selected value in prod.
It is always returning null even though something is selected since upgrading to 8.4. scriptrunner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't seem to be encountering this problem even after running a test with ScriptRunner 8.4.0.
I suggest trying to set your Jira environment to Safe Mode and only enable the ScriptRunner plugin and try to re-run the test with the latest code that I have provided to see if there is any difference.
If you are still encountering the issue even in Safe-Mode with only ScriptRunner enabled, it would be best if you are to raise a ticket on the ScriptRunner Product Support Portal, and the support team will take a closer look at the issue.
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,
I found the issue, very dumb mistake, it seems there was another custom field called the same and so it always got the value of that field instead of the one on screen.
But thank you very much for the help provided anyway.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's working for me, so I suspect you're using it differently to me.
Could you give us the snippets of code you are using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On prod environment we still are on 7.10.0 and it works. But since upgrading to 8.4 on our testing environment it stopped working.
f(issue.issueType.name == 'Save'){
if (! cfValues['Save - Root cause']?.get(null)){
return false;
}else{
return true;
}
}else{
if (! cfValues['Root cause']?.value){
return false;
}else{
return true;
}
}
I also tried
(issue.issueType.name == 'Save' && cfValues['Save - Root cause']) || cfValues['Root cause']
and when I log on prod it returns me a value on test it returns nothing anymore.
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.