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

Unable to clear error message after entering wrong value in behaviour custom field

anshu02
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.
Nov 06, 2019

We have a custom field where we want to get inputs between 1-10 only, and inputs apart from this range should give error message. So when we put incorrect value it gives the error message but after clearing the incorrect value and trying to keep the field blank it still throws error message. 

 

This is the script which we are using:

def abvField = getFieldById("customfield_12404")
def abvValue = getFieldById("customfield_12404").getValue() as Integer //Actual Business Value

if (abvValue > 10 || abvValue <1 )
{
abvField.setError("This field should contain a number value between 1-10")
}
else { abvField.clearError()}

1 answer

1 accepted

1 vote
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 06, 2019

Hi @anshu02

Seems like this is a known issue with behaviour it does not work on when field clears it keep on holds the previous value

The workaround I can suggest you to consider script validator in workflow or custom listener

you can place validator script something like below

def value = cfValues['Filed Name for validation'] as Integer
if(value){
if(value < 11 && value > 0){
return true
}
else{
return false
}
}
else{
return true

BR,

Leo

Is there still no fix for this yet? @Leo 

Really need to make use of the behavior plugin instead of the validator and this bug is causing huge trouble. 

Would really appreciate any help

I have encountered the same issue on my end as well. Can someone comment on a possible workaround?

Also seemingly stuck on this in 2023. Any suggestions please?

Looks like `clearError()` does the trick, this is working:

 

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*

def assignee = getFieldById(ASSIGNEE)
assignee.setRequired(true) // marks with red star. Unassigned still a valid value so:

def newAssignee = assignee.getValue() as String

// clear any previous error and then be sure the ticket gets assigned
assignee.clearError()
if (!newAssignee || newAssignee == "-1") {
assignee.setError("Assignee is required")
}

Suggest an answer

Log in or Sign up to answer