Calculated Checklists in Jira.

I am looking for a plugin/solution to calculate checklist values.    The checklist items need to have numberic values assigned so that they could be summed up and provide a score.  The score would need to be  queried.

 

Are there any solutions that would allow for this function in Jira?

 

1 answer

This widget could not be displayed.
Tayyab Bashir Community Champion Aug 30, 2017

Hi, 
I have implemented this solution with Script Runner's scripted fields.
If you do have this plugin then you can simple create a scripted field, and put this code in it. 

The following gets all the selected fields in multiselect and returns the sum of all the values in a field. You can futher query the resulted field in JQL. 

{code}

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def issueObject = issueManager.getIssueObject("Issue-Key")

// provide id here.
def customFieldObject = customFieldManager.getCustomFieldObject(customfieldId)

//issueObject.getCustomFieldValue(customFieldObject)
def customFieldObjects = customFieldManager.getCustomFieldObjects(issueObject)
def totalValue = 0;
if (customFieldObjects.contains(customFieldObject))
{
def cf = customFieldObjects.indexOf(customFieldObject)
def customField = customFieldObjects.get(cf)
def allValues = customField.getValue(issueObject)
def size = allValues.size()

for(int i =0; i <size; i++){
def temp =0
def intValue = Integer.parseInt(allValues[i].toString())
temp = temp + intValue
totalValue += temp;
}
}
return totalValue


{code}

 

For e.g. I had 20 and 30 selected, so it returned 50 in the TML field. 

Capture.PNGYou can futher create your custom fields and modify the code to get your own results.

Hope this helps.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

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