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 edited

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
TAGS
atlassian, jira cloud certification, managing jira projects, jira project administration, jira cloud exam, atlassian certification, agile project management, jira workflows, jira permissions, jira training, jira cloud skills, atlassian learning

Become a Certified Jira Service Project Expert 🦸🏻‍♂️

Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.

Get Certified! ✍️
AUG Leaders

Atlassian Community Events