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?
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.
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")
Maybe I've explained bad, English is not my main language.
I'll try to explain with other words
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
Welcome to your weekly Jira Ops Early access program update, where we’re sharing news and updates on Jira Ops' progress as we work toward our 1.0 release. If you ever want to drop us feedback or idea...
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!
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