I've got a Custom script validator that is testing multiple fields prior to transitioning the issue. If a field fails validation I append error text to a string that I throw as a InvalidInputException if the string is not empty. However, the error that the users sees does not have line breaks. All the error messages are just lumped together. Is there a way to do this, or maybe I'm just doing this wrong? Thanks.
def errorText = "";
if(a != b) {
errorText += 'A did not equal B.\n';
}
if(C != D) {
errorText += 'D did not equal C.\n';
}
if (errorText != "") {
throw new InvalidInputException(errorText)
}
I found the api: https://javadoc.io/doc/com.trunkplatform.opensymphony/osworkflow/latest/com/opensymphony/workflow/InvalidInputException.html
And the following sample code is worked for me
invalidInputException = new InvalidInputException('1st error message.')
invalidInputException.addError '2nd error message.'
invalidInputException.addError 'Other messages.'
return invalidInputException
I'm using Jira 8.13.1 and ScriptRunner 6.14.0
This isn't pretty, but this how I've gotten around it for now. I'm open to better solutions.
I added this to the system level announcement banner.
<style type="text/css">
div[id^="workflow-transition-"] .aui-message.error p:nth-of-type(1) {white-space: pre;}
</stye>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.