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

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

Venkata Sagar Ganesh Rao Mahendrakar September 12, 2022

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
YogeshKR
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.
September 12, 2022

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

Venkata Sagar Ganesh Rao Mahendrakar September 12, 2022

Hi @YogeshKR 

 

Thank you !! its Working 

0 votes
Venkata Sagar Ganesh Rao Mahendrakar September 12, 2022

I have written this script in ScriptRunner Behavior 

Venkata Sagar Ganesh Rao Mahendrakar September 12, 2022

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, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events