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
This is the part, where i get the attribute value from the insight custom field (only the attribute from the first object):
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()
You can use this:
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 Benutzername = customFieldManager.getCustomFieldObject(11003L) // ID von Customfield "Anfrage für"
ArrayList myValue = issue.getCustomFieldValue(Benutzername) as ArrayList
ArrayList myAttributes = []
myValue.each {
def myAttrValue = objectFacade.loadObjectAttributeBean(it.getId(), 1293).getObjectAttributeValueBeans()[0].getValue() // ID von Attribute "Benutzername AD" vom Object Person
myAttributes.add(myAttrValue)
}
log.warn myAttributes
Edit: I readed again your post. Here you go, the variable "myAttributes" have the attributes list comma separated.
Regards!
Thank you @Alejandro Suárez García
This works great!
Now i can use the variable for a DB Insert :)
Have a nice day.
best regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.