Forums

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

Trying to add validators in Jira workflow for universal validator?

shreyasjoshi11 March 31, 2023

I am trying to check for the custom field "Create sub-tasks" which is a radio button and has the following value - None, Yes, No. I want to add a validator to check if the value is either Yes or No. However, when I have placed the validator, it shows me some errors.

Here is my custom field - Create sub-tasks. 

 

SubTasks.PNG

 

Here are the errors I get.

Expression_validtaor.PNGValidator_Expression_Failed.PNG

2 answers

1 vote
Darryl Lee
Community Champion
April 1, 2023

Hey @shreyasjoshi11 - I think you're using Workflow Enhancer for Jira, yes? Huh, their validator syntax looks similar to Jira Expressions (on Cloud), but I now realize this is a DC/Server app. Neat.

So anyways, when you create a custom field of type Radio Button, if it is not set to be Required, then the "None" option shows up automatically.

But as @Alex Koxaras -Relational- correctly points out, it holds a value of 'null'.

But because you want the validator to "pass" if the custom field is NOT null, I think you need to check for the converse:

{Create Sub-tasks} != null
shreyasjoshi11 April 1, 2023

It says - Parsing of the expression has failed. Please check its syntax. You entered: {Create sub-tasks} != null. This expression will always evaluate to <b>false!</b> System message: Lexical error at line -1, column -1. Encountered: "-" (45), after : "{Create sub"

 

I am using - 

Update parameters of the 'Universal Validator' Validator for this transition.

 

Yes, it is hosted on the server rather than the cloud.

Darryl Lee
Community Champion
April 2, 2023

Ah, ok, looks like this add-on doesn't support the word 'null'. I got it to work with an expression like this:

{Create Sub-tasks} != ""

Please let us know if this works for you!

shreyasjoshi11 April 3, 2023

Still it doesn't work - 

 

Parsing of the expression has failed. Please check its syntax. You entered: {Create Sub-tasks} != &quot; &quot;. This expression will always evaluate to <b>false!</b> System message: Lexical error at line -1, column -1. Encountered: "-" (45), after : "{Create Sub"

Darryl Lee
Community Champion
April 3, 2023

Hrm. It might be case-sensitive. Try:

{Create sub-tasks} != ""

 (I got your field name wrong.)

(Also it maybe doesn't like the -.  Can you also try:

{Create sub\-tasks} != ""
Darryl Lee
Community Champion
April 4, 2023

Ooof, I gave that a try and it also did not work. You probably should contact TNG Technology's support since this is their add-on.

Or maybe @TNG Technology Consulting GmbH might be able to weigh in on this here for those of us who are interested.

The question is why in Workflow Enhancer for Jira @shreyasjoshi11 is unable to create a Universal Validator with a field name that contains a hyphen.

Matthias Bertsch [TNG Technology Consulting]
Atlassian Partner
April 4, 2023

Hello @shreyasjoshi11,

We are sorry to hear that you experience issues with Workflow Enhancer for Jira. Thanks @Darryl Lee for mentioning us.

Unfortunately, I am not able to reproduce your issue locally. Referencing fields that contain a hyphen works fine for me.

May I ask you a couple of questions:

  • Are you sure the field is called "Create sub-tasks" or might the real name be different, e.g., due to a translation configured for the field name?
  • Can you try to work with the custom field id instead, i.e., using {customfield_XXXXX} != "" with XXXXX replaced by the id of the custom field?

If this does not help, may I ask you to open a support ticket at https://tngtech.atlassian.net/servicedesk/customer/portal/16? Then, we can have a closer look together.

Like Maksim Lebedev likes this
Darryl Lee
Community Champion
April 4, 2023

Huh - really odd. I could exactly replicate @shreyasjoshi11 's issue by renaming my field "Create sub-tasks". Well, I look forward to finding out whatever the fix is. Thanks for the response, @Matthias Bertsch [TNG Technology Consulting] !

1 vote
Alex Koxaras -Relational-
Community Champion
April 1, 2023

Hi @shreyasjoshi11 ,

I'm not familiar with the specific app, but you could write the expression like:

{Create Sub-tasks} == null

It would be helpful if you could specify the app which you use.

shreyasjoshi11 April 2, 2023

It says - Parsing of the expression has failed. Please check its syntax. You entered: {Create sub-tasks} != null. This expression will always evaluate to <b>false!</b> System message: Lexical error at line -1, column -1. Encountered: "-" (45), after : "{Create sub"

I am using a universal validator and my JIRA is hosted on the server and not cloud.

Suggest an answer

Log in or Sign up to answer