Internationalize "error message" form field from Simple Scripted Validator (Script Runner)

I am using Script Runner for validating a lot of custom fields.
Now I have to translate the error messages.



I am unable to show a message depending on the user's language setting. I've tried to use a language key (from a custom plugin), i18nHelper.getText(), with no success

¿Is it possible to internationalize this form field?


Thank you!!



1 answer

You won't be able to provide a dynamic language like that with the Simple Scripted Validator, but you might be able to pull it off with a regular Scripted Validator.

Just change the string text in the exception you throw to match the user's language setting.

To get your other plugin's i18nHelper object, you may want to read up on scripting other plugins as well.

Thank you for your response.

I've tried replacing "Simple Scripted Validator" with "Custom Script Validator" but now I'm facing another issues.

When validation fails and I throw a InvalidInputException("fieldname", "error"), JIRA places the error message at the top of the dialog instead of the field's bottom. However when I use a Simple Scripted validator, JIRA places it correctly. ¿How can I show the error message at the bottom of the associate custom field?




Another difference when I use "Custom Script Validator" is that JIRA adds a header before the list of errors ("There were some errors when trying to create this issue"). Using Simple Scripted Validator only shows the message without any header. I'd like to show the error message without any header, but It is not important.

Thank you

Pass the field name to the exception constructor as an argument. From the docs:

throw new InvalidInputException("myField", "UR DOIN IT RONG")

The general messages are those without a field parameter specified:

throw new InvalidInputException("UR DOIN IT RONG IN A MOAR GENERAL WHEY")

Hi Again

Maybe I've explained bad, English is not my main language.

I'll try to explain with other words wink


I am already doing that.

throw new InvalidInputException(fieldName,errorMessage);

where fieldName is the custom field name that appears on /secure/admin/ViewCustomFields.jspa list. I have tried the translation name too.

The only way is using customfield_10029 that It is the id of the field in the form on the screen.I don't like using the id because we have multiple environments where we replicate the configuration, but the id of the fields does not have to be the same



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

19 views 2 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you