Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to set the acceptance limit for a "issue field custom field"

I have created a Issue field "TTL", where it will accept only numeric value in seconds. I need to set the limit to be accepted any where between (>= 60 seconds and <=8400 seconds). PFA. Any one kindly assist how to set the limit ?

TTL.JPG

 

 

3 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 26, 2022 • edited Sep 27, 2022

Hi @Hemanth Kumar

Why do you want to convert the form field value to a String and use Regular Expressions?

Since you have the requirement to check if the value entered into the field is from the range of 60 to 8400, why not just convert it to a numeric type, i.e. Integer or Long?

It would help if you tried something like:-

def field = getFieldById(fieldChanged)
def fieldValue = field.value as Integer

field.clearError()

if(fieldValue && (fieldValue < 60 || fieldValue > 8400)) {
field.setError('The Value Entered is out of Range')
}

Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.

I hope the sample code above helps to solve your question. :)

Thank you and Kind regards,

Ram

@Ram Kumar Aravindakshan _Adaptavist_  you are right, i have later updated as integer value. thanks for the above script, it helped.

Minor update, there was missing close bracket ')' , i have updated and used.

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 27, 2022

Hi @Hemanth Kumar

Glad to hear the solution worked for you. :)

Thanks for letting me know about the code error; I have updated the sample code.

Thank you and Kind regards,

Ram

Like Hemanth Kumar likes this
0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 21, 2022

Hi @Hemanth Kumar ,

you can't do that using builitin features. You need to use a third part plugin such as ScriptRunner to put in place a rule through a behaviour.

Fabio

Thanks! @Fabio Racobaldo _Herzum_  will see to create a script runner then

@Fabio Racobaldo _Herzum_  I was able to create script with some help of google/community and figured out to ranging from 60 to 100, but can you assist how to fix the range to 3 digit and 4 digit value. (as mentioned in above - 60 - 8400 is my requirement)

 

import com.onresolve.jira.groovy.user.FormField

FormField formField = getFieldById(getFieldChanged())
String value = formField.getFormValue() as String
if (value) {
    if (!value.matches("[6-9][0-9]|100")) {
        formField.setError("value should be bet. 60-8400")
    } else {
        formField.clearError()
    }
} else {
    formField.clearError()
}

@Ram Kumar Aravindakshan _Adaptavist_ 

I was able to create script with some help of google/community and figured out to ranging from 60 to 100, but can you please assist how to fix the range to 3 digit and 4 digit value. (as mentioned in above - 60 - 8400 is my requirement)

 

import com.onresolve.jira.groovy.user.FormField

FormField formField = getFieldById(getFieldChanged())
String value = formField.getFormValue() as String
if (value) {
    if (!value.matches("[6-9][0-9]|100")) {
        formField.setError("value should be bet. 60-8400")
    } else {
        formField.clearError()
    }
} else {
    formField.clearError()
}

Suggest an answer

Log in or Sign up to answer