Get issue generic field value by Field object (as in CustomField)

Peter Csiba July 31, 2012

I have a standard jira issue:

com.atlassian.jira.issue.Issue issue

and a field object:

com.atlassian.jira.issue.fields.Field field

My goal is to get the value of field in issue. I have checked the API and only issue.getExternalFieldValue(field) seems usable, but that is not working (java.lang.UnsupportedOperationException: Not yet implemented).

Note that this problem In case of CustomField is trivial:

issue.getCustomFieldValue(field)

3 answers

0 votes
Rustem Zinnatullin October 25, 2018

I was looking for that as well, but no luck.

I'm developing a workflow validator that is configurable - user can set any field to be validated. I can get the Field instance by field id (fixVersion, customfield_10000, or whatever), but I cannot then get it's value in context of an issue.

Any experts here?

Rustem Zinnatullin October 25, 2018

The workaround solution I used:

public String getFieldStringValue(Field field, Issue issue) {
if (field instanceof AbstractTextSystemField) {
AbstractTextSystemField textSystemField = (AbstractTextSystemField)field;
return textSystemField.getValueFromIssue(issue);
} else if (field instanceof ImmutableCustomField) {
CustomField customField = (CustomField)field;
Object value = issue.getCustomFieldValue(customField);
if (value instanceof String) {
return (String)value;
} else {
return null;
}
} else {
throw new UnsupportedOperationException("msg");
}
}

It works for string field types, however there is no guarantee that it works in all cases even for string field types.

0 votes
Peter Csiba February 16, 2017

Unfortunately, I don't work with JIRA for the last 3 years, so I didn't figure it out sad

0 votes
Philippe Asmar February 15, 2017

Any update on this issue?

Suggest an answer

Log in or Sign up to answer