Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

cfValues no longer return values

Kevin Verheyden
Contributor
June 21, 2023

Hi,

Since updating to scriptrunner 8.4 CfValues no longer return the value of the field.

Any idea why this might be happening?

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 21, 2023

Hi @Kevin Verheyden

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

Kevin Verheyden
Contributor
June 22, 2023
Jira 8.20.11
if(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;
    }    
}
But just using cfValues['Root cause']?.value or cfValues['Root cause'] returns nothing anymore when I do a log.
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 22, 2023

Hi @Kevin Verheyden

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

Kevin Verheyden
Contributor
June 22, 2023

Yes in this case for a simple validator, still the same problem.

If I add a log it also returns no value.

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 22, 2023

Hi @Kevin Verheyden

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:-

validator_config.png

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

Kevin Verheyden
Contributor
June 23, 2023

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.

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 25, 2023

Hi @Kevin Verheyden

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

Kevin Verheyden
Contributor
June 25, 2023

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.

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
June 26, 2023

Hi @Kevin Verheyden

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

Kevin Verheyden
Contributor
June 26, 2023

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.

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 21, 2023

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?

Kevin Verheyden
Contributor
June 22, 2023

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.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events