Validate the custom field

kA October 14, 2013

Hi friends,

It is possible to validate the content of the custom field before create the issue in onDemand JIRA.

i attached the screen shot.In that the summary field was required if we did not enter the details then it will show the dialog "You must specify the summary of a issue" like that for eg if the custom field accepts the numeric value, in case if we are entered the character but during the creat issue it is indicate "The field accept only the numeric value". It is possible do like that in onDemand JIRA.

Please share your thoughts,

Thanks,

Karthik A.

7 answers

1 accepted

0 votes
Answer accepted
Bharadwaj Jannu
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 14, 2013

If you have permission to create custom plugins, you create a workflow validator.

If you don't have, then you need to work Alassian Connect as prasad suggested.

when developing validator, you need to write code something like this.

InvalidInputException e=new InvalidInputException();
ArrayList<Version> CF =  (ArrayList<Version>)issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("CF"));
        			
if(CF != null && CF.size() > 1)
{	
e.addError(cfm.getCustomFieldObjectByName("CF").getId(),"Select only one version.");
        			
throw e;
}

this CF is a customfield of multiselect type similar to versions. I place some condition that it should contain only one version in the list.

similarly you can place a regular expression like [1-9]{1}[0-9]{9}. you go through

https://answers.atlassian.com/questions/195074/entry-validation to use regular expression using java Pattern class

1 vote
kA October 14, 2013

The validators only check whether the field has an entry or not but the validators cannot check with field value.

1 vote
RambanamP
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 14, 2013

you have to develop your own validator to implement that validation

as your instance on ondemand you have to develop validator using atlassian connect

https://developer.atlassian.com/display/AC/Atlassian+Connect

Susany July 28, 2015

I upticked your comment because I like the link - but I am trying to validate if a checkbox is checked. I think the Atlassian+Connect is too far away from a simple solution.

1 vote
John Bishop
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 14, 2013

You could set up conditions in your workflow transitions. That would allow you to validate field values and prevent issues from being created with invalid data.

0 votes
kA October 14, 2013

I just click the value field from the condition, then i got the page.In that page i can able to check with single value alone. But i need to check the more than one value using one common regular expression. It is possible to set.

RambanamP
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 14, 2013

condition does't help in your case, i don't think there is a validator to validate number field length in jira ondemand instance.

using javascript we can validate but i am not sure we can update javascript on ondemand.

so you have to develop your own validator using atlassian connect

0 votes
kA October 14, 2013

Hi John,

During create the issue the Validators and PostFunction are available but the condition tab does not exists.

John Bishop
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 14, 2013

ok. I was going off of memory, and I forgot that. Conditions are available on all transitions except for create.

Then you should create validators to verify the field information when creating the issue.

0 votes
Jobin Kuruvilla [Adaptavist]
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 14, 2013

yes, those are the default behavior in JIRA. Are you not getting those validation errors?

kA October 14, 2013

hi Jobin,

i got the error but i need to change the message for my field.The field only accepts the 10 digit phone number. In case we are wrongly enter more than 10 digit or character it will display the message "The field accepts only 10 digit".like that i need it. it is possible in onDemand JIRA. The message will be displayed before we are going to create the issue.

Suggest an answer

Log in or Sign up to answer