Forums

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

Need help in Scriptrunner validator (expression)

raju mandapaka January 17, 2024

Hello,

Need help in scriptrunner validator (expression) for multiline custom field. The requirement is to restrict the transition if that field (Multi line text field) is blank.

Tried using following expressions in scriptrunner validator but its working as expected.

issue.customfield_10073.plainText.length >1 

issue.customfield_10073.length >1

issue.customfield_10221 != null

 

Please help me with the expression.

 

Thanks in advance.

 

3 answers

0 votes
Tukaram Bhukya
Contributor
February 27, 2025

We are trying to check a similar case.   We are using multiline textfield, checking its value at transition, and adding a script at validators ( using jira expression).  It works correctly the first time, but it fails if we remove the value and transition again.

We are using this expression   "issue.customfield_11430 != null ".

I tried to use issue.customfield_11430 != "" && issue.customfield_11430.trim() != ""  but it won't work. 

I noticed it's failing for multi-line fields but works correctly for single-line text fields.

If anyone has any idea, please help me.

0 votes
Kristian Walker _Adaptavist_
Community Champion
January 18, 2024

Hi,Raju,

I think all you need to do is not have the plainText part of your first expression whcih means you can do issue.customfield_10073.length >0 to ensure a multi line text field is not empty. 

I hope this helps.

Regards,

Kristian

raju mandapaka January 18, 2024

Hi @Kristian Walker _Adaptavist_ 

I already tried this, but it is not working. here are some of the screen shots.

image.pngimage.png

In above case, it should be true.

 

Please advice.

 

Thanks,

Raju

Kristian Walker _Adaptavist_
Community Champion
January 18, 2024

Hi Raju,

I have tested this expression in my instance with a multi-line text custom field, and it works as expected.

Can you please save the actual validator and run this as I believe it will run as expected when the workflow transition is run as the issue you are seeing is just the test not recognising the field type correctly.

 

Regards,

Kristian

0 votes
Trudy Claspill
Community Champion
January 17, 2024

Hello @raju mandapaka 

You don't need to use a ScriptRunner for that.

You can accomplish that using the native Field Required Validator.

raju mandapaka January 17, 2024

Hi @Trudy Claspill 

Yes, I'm aware of it, but we are having some other fields also in that list and we need to populate dynamic error message (means if, out of 5 fields 4 fields are updated - the error message should display only for the last field which is to be filled and that needs to be done at transition screen level, which we can't do it by Field required validator.

 

Thanks,

Raju

Suggest an answer

Log in or Sign up to answer