Forums

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

Unable to create question in Questions for confluence

Aurelien Le Bastard
August 21, 2017

When I click on create question, in the new page I can't type texte in the box "What do you want to know?".

Capture.JPG

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
June 21, 2022

What you are getting is an ArrayList of  "objectBean" objects. In your case, there is a single value in that list.

The array list and the object bean happen to have some default string representation that causes the output to look like "[Alabama (IAS-575858)]"

If the attribute you want happens to be the Label (or if you're only interested in the key)you can get either with something like this:

import com.atlassian.jira.component.ComponentAccessor
def im = ComponentAccessor.issueManager
def issue = im.getIssueObject("IPT-88")
def customFieldManager = ComponentAccessor.gcustomFieldManager

def stateCf= customFieldManager.getCustomFieldObject("customfield_15500")
def cfValue = issue.getCustomFieldValue(stateCf)

def stateObject = cfValue[0]

def objectLabel = stateObject.label
def objectKey = stateObject.objectKey

 

But if you want to retrieve a value for a specific attribute (that isn't the label), then it gets a bit more complicated.

import com.atlassian.jira.component.ComponentAccessor

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade
@WithPlugin('com.riadalabs.jira.plugins.insight')
@PluginModule ObjectTypeFacade objectTypeFacade
@PluginModule ObjectTypeAttributeFacade objectTypeAttributeFacade

def im = ComponentAccessor.issueManager
def issue = im.getIssueObject("IPT-88")
def customFieldManager = ComponentAccessor.gcustomFieldManager

def stateCf= customFieldManager.getCustomFieldObject("customfield_15500")
def cfValue = issue.getCustomFieldValue(stateCf)

def stateObject = cfValue[0]

def attributeName = "State Name"
def objectType = objectTypeFacade.loadObjectType(stateObject.objectTypeId)
def attributeBean = objectTypeAttributeFacade.findObjectTypeAttributeBeans(objectType.id).find{ it.name == attributeName}

def attributeValues = stateObject.objectAttributeBeans.find{it.objectTypeAttributeId == attributeBean.id}?.objectAttributeValueBeans*.value

//all attribtutes are stored as list, even when max cardinality = 1
//so we get the first one here
if(attributeValues){
def stateName = attributeValues[0]
}

I wrote an article with some examples: https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Interacting-with-Insight-objects-from-Scriptrunner-Server-Data/ba-p/1649857

This shows how it can be simplified with a utility class.

Kurtis Schmitz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 24, 2022

Thanks for your help! This is exactly what I was looking for and is far more reliable then the substring manipulation I was going to do instead haha.

Based on the things shown here I can actually put it all into one degenerate line of code.

def USState = (issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_15500"))).label[0]


I'm not trying to call attributes other then the label at present, but I'm bookmarking this post in case I do later and will definitely take a look at your guide if that happens. 

Once again thanks a million for your assistance here!

TAGS
AUG Leaders

Atlassian Community Events