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

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

Jira Insight Groovy Condition

Edited

I'm trying to create a groovy script to perform a condition based on the attribute value of an insight custom field. The problem is the attribute value I require is a referenced object which is again another referenced object.

For example I have a object called computer with an attribute called "Computer Model" that is a referenced object. The "Computer Model" object has an attribute called "Manufacturer" that is also a referenced object. The Manufacturer object just has one attribute called name which I require the value of.

I have modified some code I have used in the past that is currently outputting the object id of the Computer Model.

 

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

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)

CustomField Warranty = customFieldManager.getCustomFieldObject('customfield_10800')
ArrayList myValue = issue.getCustomFieldValue(Warranty) as ArrayList
ArrayList myAttributes = []

myValue.each {
if (objectFacade.loadObjectAttributeBean(it.getId(), 237))
{def myAttrValue = objectFacade.loadObjectAttributeBean(it.getId(), 237).getObjectAttributeValueBeans()[0].getValue()
myAttributes.add(myAttrValue)}
}

return myAttributes[0]

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

107 views 1 8
Read article

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