Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to query or pull information from a Jira ticekt.

Tory Dennis
March 29, 2023

I would like to know if there is a way to get information from Jira tickets and append it to a on-going list?

I looked through some of the documentation but im not sure what i would need or if there is an application i can use.

The only options i found so far is to either export the ticket as a XML or Word.

3 answers

1 accepted

1 vote
Answer accepted
Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

Actually they are same.

Anyway, for sure you have to add null check

<!-- @@Formula:

Object cf1Val = issue.get("customfield_11309");
Object cf2Val = issue.get("customfield_11310");
Object cf3Val = issue.get("customfield_11311");
Object cf4Val = issue.get("customfield_11312");
Object cf5Val = issue.get("customfield_11313");
int sum = ((cf1Val != null ? Integer.parseInt(cf1Val.toString()) : 0 )) 
+ ((cf2Val != null ? Integer.parseInt(cf2Val.toString()) : 0 ))
+ ((cf3Val != null ? Integer.parseInt(cf3Val.toString()) : 0 ))
+ ((cf4Val != null ? Integer.parseInt(cf4Val.toString()) : 0 ))
+ ((cf5Val != null ? Integer.parseInt(cf5Val.toString()) : 0 ));

Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

So, any update? Does this code work?

Joe Harmon
Contributor
May 24, 2018

No for some reason it doesn't work.  I copied it in just as you have it.  Is there a way to debug it?  Does it output to any specific logs?

Tuncay Senturk _Snapbytes_
Community Champion
May 24, 2018

It should definitely work.

Did you return the value.

It should be as below

<!-- @@Formula:

Object cf1Val = issue.get("customfield_11309"); Object cf2Val = issue.get("customfield_11310"); Object cf3Val = issue.get("customfield_11311");
Object cf4Val = issue.get("customfield_11312");
Object cf5Val = issue.get("customfield_11313");

int sum = ((cf1Val != null ? Integer.parseInt(cf1Val.toString()) : 0 ))
+ ((cf2Val != null ? Integer.parseInt(cf2Val.toString()) : 0 ))
+ ((cf3Val != null ? Integer.parseInt(cf3Val.toString()) : 0 ))
+ ((cf4Val != null ? Integer.parseInt(cf4Val.toString()) : 0 ))
+ ((cf5Val != null ? Integer.parseInt(cf5Val.toString()) : 0 ));

return sum;
-->
Like Jen Adel likes this
Joe Harmon
Contributor
May 24, 2018

It's working.  Thanks for all your help.

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
May 24, 2018

Glad to hear that. So please accept the answer for the further usages.

Joe Harmon
Contributor
May 24, 2018

done

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

Hello,

You're getting 11111 because you're concating five 1

You should cast the result to integer before adding.

Integer.parseInt(...) + Integer.parseInt(...) + ...

 or 

(Integer)issue.getCustomFieldValue(cf1) + (Integer)issue.getCustomFieldValue(cf2) + ...
Joe Harmon
Contributor
May 23, 2018

Thanks for the response.  For some reason, (Interger)issue.getCustomFieldValue("customfield_11313") isn't returning a value for any of the plugged in custom fields.

Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

What is your custom fields' (11309, and others) type?

And what does below statement return?

issue.get("customfield_11309")

 

Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

By the way, cf1 is not "customfield_11309"

CustomField cf1 = customFieldManager.getCustomFieldObject("customfield_11309")
Joe Harmon
Contributor
May 23, 2018

All 5 custom fields are "Select List (single choice)" custom files.  I then have in the list the values of 0, 1, 2, 3.  But I suspect that it is being seen as text and not a numeric value.

issue.get("customfield_11309") returns the current set value of that field (currently set to 2)

Tuncay Senturk _Snapbytes_
Community Champion
May 23, 2018

OK, then try this one

int cf1Val = Integer.parseInt(issue.get("customfield_11309"))
int cf2Val = Integer.parseInt(issue.get("customfield_11310"))
int cf3Val = Integer.parseInt(issue.get("customfield_11311"))
int cf4Val = Integer.parseInt(issue.get("customfield_11312"))
int cf5Val = Integer.parseInt(issue.get("customfield_11313"))

int total = cf1Val + cf2val + cf3Val + cf4Val + cf5Val
Joe Harmon
Contributor
May 23, 2018

Nope, that one didn't work, but this one does if all the fields are set:

<!-- @@Formula:
Integer.parseInt(issue.get("customfield_11309"))+
Integer.parseInt(issue.get("customfield_11310"))+
Integer.parseInt(issue.get("customfield_11311"))+
Integer.parseInt(issue.get("customfield_11312"))+
Integer.parseInt(issue.get("customfield_11313"))
-->

If any of the fields are set to none or not set, then it doesn't work.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events