0

Three developers have spent a better part of an afternoon try to solve this:

I have a text custom field that doesn't accept certain characters. JIRA has this validation built-in, but I want to go one step further and highlight exactly what character was invalid.

I thought I should override CreateIssueDetails.doValidate(), get the custom field value, check for the invalid characters, and send back an error. But my customField.getValue(issueObject) call always returns null. The code is simple:

CustomField field = getCustomFieldManager().getCustomFieldObjectByName("custom_field");
String value = (String)field.getValue(getIssueObject());

However, no matter how I try, the value is always null. Has the fieldValue not been set yet since I'm still in validate? If so, where do I find the value that's in the text box?? I thought maybe it would be in some temporary holding area, awaiting to be inserted into the database, but I can't figure out what that would be. getFieldValuesHolder() returns null.

Any thoughts??

CNDyson
  • 1,687
  • 7
  • 28
  • 63

1 Answers1

0

I've discovered that I can get the original field values directly from the HttpRequest. I use:

String[] string = ActionContext.getRequest().getParameterValues(fieldId);
CNDyson
  • 1,687
  • 7
  • 28
  • 63
  • That's one way to do it. But if you're creating your own custom field type by extending one of the Text custom field types I'd use getValueFromCustomFieldParams() which allows you to reject using throw new FieldValidationException() – mdoar Jan 31 '13 at 20:39