Forums

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

Sum of Select List custom field

Michael Sellner April 23, 2022

Greetings!

I have a project I'm playing with in a test environment where I've reached a couple stumbling blocks.  I'm new to Jira admin and creating projects from the ground up, but I'm a quick study.

Project:

This will be used for attendance infraction tracking. Supervisors may enter occurrence values of 0.00, 0.25, or 1.00 through a Select List (single choice) field. (Ugh, I just learned that this stores the data as a string. Not ideal.) (Is there a better way? I'd prefer to not let supervisors enter via an open field.) (This is customfield_25002)

Once that's done, I have JQL that will show me all events that match certain filters, but I need a way to sum the customfield_25002 on all matching issues. I think a JMCF field will do it, but I'm banging my head against the wall.

I can't seem to get customfield_25002 to behave as an Integer. I'm not the best coder, so I looked at and tested a few scripts from google (and these boards) to no avail.

I have scriptrunner available, so there's got to be a way to make this happen with the tools at my disposal, but I'm lost.  Any help would be nice.  Thanks in advance.

I even tried creating a new field I would hide simply to convert the string to int, but can't seem to get anything to work.
To be clear:

1) Is there a way to have a selectable list saved as an integer?

2) How would I sum all values of customfield_25002 but only on issues matching something like :

project = TEST AND issuetype = Attendance AND "Occurrence Value?" in (0.25, 1.00) AND "Absence Date" >= -26w ORDER BY cf[21100] ASC, cf[25001] ASC, cf[25002] ASC, created DESC

2 answers

0 votes
Fabio Racobaldo _Herzum_
Community Champion
April 24, 2022

Hi @Michael Sellner ,

welcome to the Atlassian community!

If I well understand your question, you need a way to sum values coming from differnt issues through a JQL. Please try the following plugin https://marketplace.atlassian.com/apps/1211625/sumup-for-jira?hosting=server&tab=overview

Hope this helps,

Fabio

Michael Sellner April 24, 2022

I appreciate you!  Thanks for the response.

Unfortunately, right now I am unable to pay for a license so I won't be able to use anything that's not free.

0 votes
David Fischer
Community Champion
April 23, 2022

Hi @Michael Sellner 

To transform a string into an integer, you can use Integer.parseInt(...). For example,

Integer.parseInt(issue.get("customfield_25002"))

But what I don't understand is where you want to display the sum of that field across multiple issues. JMCF calculated fields apply to individual issues, just like any Jira field. What you are looking for applies to a set of issues, and I don't see where you would display that value.  

Michael Sellner April 24, 2022

Well, several places.

I was hoping in a JMCF custom field I could sum all of those custom fields that match a query like above, except it appears I left out the user picker, which is another field in the issue.

I also want to use it in custom scripting, if that same query above is above 4, send a notice, above 5 send a different notice, and at or above 6 yet another notice. I think I can figure that part out if I can get this JMCF field working properly

David Fischer
Community Champion
April 24, 2022

Hi @Michael Sellner ,

Custom fields are associated with issues. You cannot calculate a custom field value outside of the context of a single issue. 

If you're trying to write a ScriptRunner script that will select issues using the jql query and then send an email based on these issues, you don't need a calculated field, you can run the calculation directly in the script. 

Suggest an answer

Log in or Sign up to answer