Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner - How to get attribute values from insight customfield (multiobject/multi user field)

Florian Schüller
Contributor
February 10, 2019

Hi Community!

I try to get the attribute values from a multi user/multi object insight custom field.

I tried a lot, but i only get the attribute value from the first object. (the object which is alphabetic first)

I would like to get the attribute values comma seperated as result.

If someone could help me i would be very grateful :)

best regards,

Florian

 

Here is the part of my code:


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 Benutzername = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11003) // ID von Customfield "Anfrage für"
def myValue = Benutzername.getValue(issue)
def myObjectBean = myValue[0]
def myAttrValue = objectFacade.loadObjectAttributeBean(myObjectBean.getId(), 1293).getObjectAttributeValueBeans()[0]; // ID von Attribute "Benutzername AD" vom Object Person
def myString = myAttrValue.getValue()

 

The problem is, that i get only one attribute from the first object of the multiselect field.

2 answers

1 accepted

3 votes
Answer accepted
Florian Schüller
Contributor
February 11, 2019

This is the part, where i get the attribute value from the insight custom field:

The problem is, that i get only one attribute from the first object of the multiselect field.

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 Benutzername = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11003) // ID von Customfield "Anfrage für"
def myValue = Benutzername.getValue(issue)
def myObjectBean = myValue[0]
def myAttrValue = objectFacade.loadObjectAttributeBean(myObjectBean.getId(), 1293).getObjectAttributeValueBeans()[0]; // ID von Attribute "Benutzername AD" vom Object Person
def myString = myAttrValue.getValue()
0 votes
Viktor Kuzmychov
Contributor
September 30, 2020

Hi Florian,

It's been a while, but just for the sake of other seeking, your problem is in this string:

def myAttrValue = objectFacade.loadObjectAttributeBean(myObjectBean.getId(), 1293).getObjectAttributeValueBeans()[0]

[0] means get the first object from the pile. 

Good luck

Suggest an answer

Log in or Sign up to answer