How to access Insight object attributes in Script listener Edited

In an Insight groovy script post function you can access Insight-objects and their attributes with this kind of syntax;

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField;

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

CustomField myCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10235) // id of custom field
def myValue = myCF.getValue(issue)
def myObjectBean = myValue[0]
def myAttrValue = objectFacade.loadObjectAttributeBean(myObjectBean.getId(), 517).getObjectAttributeValueBeans()[0]; //attribute id
def myString = myAttrValue.getValue()

 

I can't this kind of code to work in a  Script runner event listener.

My idea is to update an issue in a script listener using attribute values from Insight Custom fields.

Any ideas how to do this?

1 answer

This widget could not be displayed.

Hi Magnus,

What is it that is not working, what kind of exceptions do you get?

Looking at the code, one possible nullpointer is the issue variable. I know that in Insight, this variable is preloaded with the current issue, I guess that is the same for Script runner, but not sure.

Best Regards
Alexander

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 16 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

42 views 1 0
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