Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,979
Community Members
 
Community Events
168
Community Groups

When i enter a value in custom field need to get an Error Message

Hi Team

I have written a script like when field value not equal to null then i should get error message 

def field = getFieldByName("Alternate Approver")
def fieldvalue = field.getValue()

if(fieldvalue!= null)
{
field.setError("Error Message")
}

 

but the above script is showing error message when value is empty also

 

Please help me on this 

Thanks 

Sagar 

2 answers

1 accepted

2 votes
Answer accepted

Hi @Venkata Sagar Ganesh Rao Mahendrakar

Please try using below script, 

def field = getFieldByName("Alternate Approver")
def val = field.formValue as String
if (val) {
field.setError("Error Message")
}
else {
field.clearError()
}

Hope this helps you ! 

Regards,
Yogesh

I have written this script in ScriptRunner Behavior 

Hi 

Even tried below not working 

def field = getFieldByName("Alternate Approver")
def fieldvalue = field.getValue()

field.clearError();

if(fieldvalue!= null)
{
field.setError("Error Message")
}

 

Please Help Me 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events