Forums

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

Simple Scripted Validator - Custom Filed characters limitation

Wojtek Drozdz August 10, 2018

Hi All,

I'm trying to make a Custom Filed characters limitation while creating an epic. 

I've tried 2 possibilities but it didn't work, let me share them with you.

1.

Go to Project Setting > Workflows

Edit the workflow for the affected issue type

Switch to Diagram mode

On Create transition, click on the Validators

Choose Add Validator > Regular Expression Check

- > Well I do not have such an option in my Jira ....

 

2. 

I used a simple script validator :

String myCF = cfValues["Summary"];
if (myCF.length() == 4 && myCF.isInteger()) {
    1 == 1;
}

Well in that case if I put more than 4 character , indeed there is a error msg, but if I put 4 or less characters there also the error msg. 

Do I have something wrong in my script ? 

Thank you, dear community, for your help :) 

 

Regards,
Wojtek

 

2 answers

2 accepted

1 vote
Answer accepted
Alexey Matveev
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 10, 2018

Hello,

Your script shold look like this:

String myCF = cfValues["Summary"];
if (myCF.length() == 4 && myCF.isInteger()) {
   return true;
}
return false;
Wojtek Drozdz August 10, 2018

Hi Alexey,

Thank you for your answer. 


I've tried your script and I have the same situation as with the 1st one.

" I put more than 4 character , indeed there is a error msg, but if I put 4 or less characters there also the error msg. " 

It's very strange. 

0 votes
Answer accepted
Mark Markov
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 10, 2018

Hello @Wojtek Drozdz

Are you trying to validate some custom field that calls summary or system field summary?

If system it should be like this:

issue.summary.length() < 5

this condition validates that summary have 4 characters or fewer

And for custom field:

cfValues['Summary'].length() < 5

In your condition you also checks that summary field is integer. Is this requriment?

Wojtek Drozdz August 10, 2018

Hi Mark,

 

Thank you. 

My question is for a Custom Field - not the "system" filed. 

 

Unfortunately your code didn't work :/

 

Have you maybe another solution ? 

 

Thank you again !

 

BR,
Wojtek

Suggest an answer

Log in or Sign up to answer