Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,659
Community Members
 
Community Events
184
Community Groups

issue.getField() returns null

wonder wolf
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 06, 2023

I'm trying to get a value from a specific field that determines at runtime. I was trying to check for fields by calling issue.getFields(), but it still returns null. The only one kind of method that returns value properly - method with specified in advance field (example:
issue.getSummary();)
Main method

JiraRestClient restClient = getJiraRestClient(); \\custom method for connecting in jira local server
SearchRestClient searchClient = restClient.getSearchClient();
SearchResult searchResult = searchClient.searchJql(jql, -1, 0, fields).claim();
JsonArrayBuilder issueArrayBuilder = Json.createArrayBuilder();
for (Issue issue : searchResult.getIssues()) {
Issue initIssue = restClient.getIssueClient().getIssue(issue.getKey()).claim();
JsonObjectBuilder jsonIssueBuilder = Json.createObjectBuilder();
for (String field : fields) {
JsonValue jsonValue = getJsonValueForField(initIssue, field);
jsonIssueBuilder.add(field, jsonValue);
}
JsonObject jsonIssue = jsonIssueBuilder.build();
issueArrayBuilder.add(jsonIssue);
}
return issueArrayBuilder.build();


private static JsonValue getJsonValueForField(Issue issue, String field) {
IssueField issueField = issue.getField(field);
 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events