Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Numerical calculation of an Insight attribute field Edited

Hello all,

we are trying to calculate a priority for an Insight object, based on different categories. The whole thing looks like the following example:

Object A:
Attribute Priority Categories: Multiple selection from category 1-5
Attribute Priority: Numeric calculated value based on priority categories

Category 1: Value of 20
Category 2: value of 50
Category 3: value of 10
So if an object A has category 1 and 2, the value 70 should be calculated as priority.

Does anyone have ideas what possibilities can be offered for this?

Thanks in advance for your help!

1 answer

The actual logic for this is fairly simple ... what's hard is to get the Category values and then update another attribute.

With the utility class I created (see this article) I can achieve your requirement with this script in the insight groovy console:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.util.JiraHome
def jiraHome = ComponentAccessor.getComponent(JiraHome).home
InsightUtils = new GroovyClassLoader(getClass().classLoader).parseClass(new File("$jiraHome/scripts/com/qad/qsm/jira/insight/InsightUtils.groovy"))
def cat = InsightUtils.getAttributeValueFromDotNotation(object, 'Priority Category') as List
def map = ['Category 1':20, 'Category 2':50, 'Category 3':10]
def priority = cat.sum { map[it] }
InsightUtils.setObjectAttribute(object, 'Priority', priority)


To do the same from scratch, it would look more like this:

import com.atlassian.jira.component.ComponentAccessor
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade)
def objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeFacade)
def objectTypeAttributeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeAttributeFacade)

def objectType = objectTypeFacade.loadObjectType(object.objectTypeId)
def priorityCategoryAttr = objectTypeAttributeFacade.findObjectTypeAttributeBeans( { == 'Priority Category'}
def priorityAttr = objectTypeAttributeFacade.findObjectTypeAttributeBeans( { == 'Priority'}

def categories = object.objectAttributeBeans.find{it.objectTypeAttributeId ==}?.objectAttributeValueBeans*.value

def categoryPrioritValuesMap = ['Category 1':20, 'Category 2':50, 'Category 3':10]
def priority = categories.sum { categoryPrioritValuesMap[it] }"Priority will be set to $priority")

def newPriorityBean = object.createObjectAttributeBean(priorityAttr)
def newPriorityValue = newPriorityBean.createObjectAttributeValueBean()

newPriorityValue.setValue(priorityAttr, priority)


Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you