Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,301,533
Community Members
 
Community Events
165
Community Groups

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

📅 Partner Webinar & Events Opportunities: July 2022

Hi community 👋, Here is another monthly roundup of the partner-organized events in July 2022. If there is any event missing please let me know in the comments below 🙏 If you're looking for Atla...

29 views 0 2
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