How to Validate custom field (Select List type)

Tomasz Puk October 21, 2012

Hi,

I have a custome filed "Pre Risk Identified" of Select List type. In the list I have two choices specified:

'Yes'
'No'

added.

In one of the screens I would like to validate that this field has been filled in with either Yes or No values (there i still None available in the slect list).

I would need a validator condition which would check if this field is not empty and with specific value assigned. I would not like to use external plugins for that purpose if possible.

Regards,

Tomek

6 answers

1 accepted

3 votes
Answer accepted
Tomasz Puk October 22, 2012

Hi All,

Thank you very much for your support. Finally it was resolved by:

  1. Adding a validator on a transition.
  2. Selecting Simple scripted validator
  3. Adding a condition: cfValues['My Field Name'] != null
  4. Choosing the Field it applies to and adding a comment in case condition fails

It works this way that it focuses user to choose one of the options and triggers the messgae when 'None' is selected.

Again, thank you for your answers.

Regards,

Tomek

1 vote
aristeinberg February 28, 2013

Hi,

I have a very similar problem. but would like to verify that a string value is present. Any idea how? I've tried is not EMPTY and != Null but in all cases i get the error regardless of the input.

0 votes
Sergio Rill May 30, 2013

Hi,

I have the same problem. I need to verify if value of cf select list is equal to 'Service', if equals the user can t create the issue. Somebody have the script runner script for this??

Regards

0 votes
KhongMingA
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.
October 22, 2012

Hi Tomasz,

I am afraid that there no default way for JIRA to set validator of the field.
I understand that you do not want to use external plugins, perhaps you can create your own custom field type.

You might want to refer to this documentation on How to create a new Custom Field Type.

However, if you wondering a workaround on to use plugins.
- JIRA Suites Utilities using the value field conditions

Thanks

Warmest Regards,
KM


Tomasz Puk October 22, 2012

Hi KM,

We have to exclude external plugins as they have already caused us problems. In some cases they just stay behind JIRA releases what is a problem for resonably big deployment like ours.

I will try then own custome field type.

Thank you for your help.

Regards,

Tomek

0 votes
Bhushan Nagaraj
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.
October 22, 2012

Hi Tomasz,

You will need a workflow validator plugin and writing one for this would be pretty simple. I can post some code if you would like.

Cheers

Bhushan

Tomasz Puk October 22, 2012

Hi Bhushan,

That would be great if there is no other way to achive it.

Thank you.

Tomek

0 votes
Immanuel Siagian
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.
October 22, 2012

Hi Tomek,

In one of the screens I would like to validate that this field has been filled in with either Yes or No values (there i still None available in the select list).

The best way to achieve this to make the custom field required, as this will guaranteed that the custom field will have a value before submitting it.

For more info you can refer to the following doco:

Cheers

Tomasz Puk October 22, 2012

Hi Immanuel,

Thank you for the hint. The additional problem in that case is that the field is not required all the time but only one some transitions between states. I knew I would miss something in the description, sorry ;). That unfortunately eliminates making this filed required.

I know that there are some plugins which can make field required on a transition but we would like to use pure Confluence functionality for this - it makes Confluence maintenance a bit easier.

I would really like to use validators for this purpose as they seem the fit for purpose here. Any hint how to do that?

Once again thank you for your support.

Regards,

Tomek

Suggest an answer

Log in or Sign up to answer