Scriptrunner workflow validator behaves differently when transition from board or issue view

Emilie
Contributor
February 10, 2025

Hello,

We define a workflow validator with Scriptrunner, to allow the transition only if a custom field (text field, with Wiki Style Renderer) is not empty.

The Jira expression is:

issue.customfield_10052 != null && issue.customfield_10052.trim().length > 0 

The validator is OK when we test it from Scriptrunner Workflow Overview:

validator.png

The validator works correctly when we transition the issue from a board.

But when we want to transition the issue from the issue view, we get this error:

"errorMessages": [ "Evaluation failed: \"issue.customfield_10052.length > 0\" - operator \">\" is not applicable to types: null and Number" ] 

and the error message popup is displayed:

validator-2.jpg

Can you please help me understand why the behaviour is different in both views and how to fix this, so that the validator works wherever the transition is done?

Thanks.

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Jorge Guerreiro
Contributor
February 12, 2025

Hi Emilie, this document should give you an overview of the changes Atlassian implemented a couple of months back regarding the usage of the new v3 api to execute these transitions

the new experience employs the REST v3 API for Issue Submit utilizing the ADF format, compared to the REST v2 API for Issue Submit utilizing Plain String format based on Wiki Markup. As a result of these format alterations, workflow validators and post functions relying on RichText fields are incapable of parsing the text from the ADF representation, leading to validation failures. Consequently, users may encounter difficulties in transitioning issues

Hopefully this will help you reach your goal!

Thanks

Emilie
Contributor
February 12, 2025

Hi Jorge,

That's it: it works as expected (both on board and issue view) with the RichText constructor from ADF Map.

Thanks a lot!

Like Jorge Guerreiro likes this
0 votes
Tomasz Kowalczyk
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.
February 11, 2025

I'm not sure if i properly understand the problem but error just says that you can not check if null is greater then 0. So if you have null in that field it just fails. I just don't understand when you said that sometime it works - on same issue and same customfield values it works on transitioning from boards and on issue view it fails? it would be interesting but maybe on transitioning issue on boards it is not checking validators?

Emilie
Contributor
February 12, 2025

That's it: on a same issue and so the same customfield values:

  • if the field is empty
    • I can't transition from the board
    • I can't transition from the issue view
    • this means the board checks the validator and behaves as expected
  • if the field is not empty
    • I can transition from the board -> which is OK
    • I can't transition from the issue view -> wich is not OK

And it's the same for the validators we base on text customfields.

What we do:

  • we check that the field exists: issue.customfield_10052 != null
  • and is not empty: issue.customfield_10052.trim().length > 0 

Maybe that's not the correct way to achieve that with the Jira expression, I don't really know as it's OK from the board.

The errors began Jan 29.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events