Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to validate the field must be numerical and longs 12 characters?

Nicolas Andika August 19, 2024

Dear all,

i have created a custom fields (free text type) called Contract Number, i want to validate when create an issue, user must input the contract number fields with a numerical value and longs 12 characters, how to make it possible? is it from the workflow or any other choice? i have JMWE as and addon or should i change another custom fields type?

Thankyou

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Prosper Agwegiokhe August 19, 2024

Hi,

I’m Prosper, a support engineer at Appfire, and I’m here to help you.

Based on your question, yes you can add a validator via the workflow to validate the input field when the issue is created.

You can use the Field Required Validator to conditionally validate issue fields by editing the workflow and creating a validator.
Screenshot 2024-08-19 104713.png

I attached an example image showing a sample validator to fit your use case. You can use the Issue Fields dropdown to get the id of the custom field and then add you desired condition.

Screenshot 2024-08-19 114038.png

You can check out this documentation for more information or please contact our support if you have any other questions about this query.

We’ll be happy to help you!

Best regards,
Prosper.

Nicolas Andika August 19, 2024

Hi @Prosper Agwegiokhe 

Thankyou for the support, it really helps, one more question, can we validate the value must be numerical? 

Nicolas Andika August 19, 2024

Hi @Prosper Agwegiokhe 

i have tried the suggestion that you shared above, but it seems not working, i think because the conditional validation is for condition that must be true to make the validator work, is there any possible ways to make it happen? 

Thankyou

Prosper Agwegiokhe August 21, 2024

Hi @Nicolas Andika

Apologies for the late response, and you are correct, the conditional validation must be true for the validation to work.

The approach to take would be to "Build-your-own Validator". I tested with this function:


issue.customfield_10166 != null && issue.customfield_10166.length == 12 && issue.customfield_10166.split('').every(char => char >= '0' && char <= '9')


and it worked as expected. It is also worth mentioning i tested this with the short text (plain text only) custom field as it doesn't seem to work with rich text.
Screenshot 2024-08-21 143302.png

Please try this out and let me know if it resolved your issue.

Regards,
Prosper.

0 votes
Lisa Forstberg
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.
August 19, 2024

HI @Nicolas Andika ,

I think you should be able to validate this with JMWE

You need to decide if you want to have the validation running whenever anyone is  editing the field or via  a transition step in the worklow.

I have seen this blog describe what I think you're after.

 

best of luck

/Lisa

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

Atlassian Community Events