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

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

Any update on this issue?

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

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?

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,098 views 4 9
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