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()}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have encountered the same issue on my end as well. Can someone comment on a possible workaround?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also seemingly stuck on this in 2023. Any suggestions please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.