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

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

 

scripted_yellow.png

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?

  

error_at_top.jpg

 

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Stride

Get Started in Stride in 3 Easy Steps

Get started on Stride in 3 easy steps   If you’re new to Stride, welcome! We’re super excited to have you aboard. Stride is easy to use and set up, so don’t worry about reading tons of borin...

54 views 0 2
Read article

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