Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Insight attribute value to insight customfield

Jorden Van Bogaert
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 Leaders.
December 26, 2019

Hi

I'm currently writing a groovy script that runs in insight automation. Basically what it does is creating a Jira issue, but with some advanced requirements.

The insight object has 2 attributes which reference other insight objects. 
attribute#1 = insight object
attribute#2 = insight object

Now I need to get the object from each attribute and put them into 1 insight custom field on the issue that was just created.

Jira issue
- insight custom field = [attribute#1.object, attribute#2.object]

I've tried multiple ways, but I'm unable to put both values into the field. Does the custom field require a list, or an array or how should I bundle the 2 objects to store them into the 1 custom field?

Thanks in advance!

1 answer

1 accepted

2 votes
Answer accepted
Ilya Turov
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 Leaders.
December 26, 2019

Hello, 

are you sure you can a. put more than one element in that field?

b. put either of attribute1 and attribute2 in that field?

basically, can you do it manually?

Jorden Van Bogaert
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 Leaders.
December 26, 2019

Hi @Ilya Turov 

Thanks for your response. Yes, the field is multi value and both values that I use to test can be added to the field manually.

Ilya Turov
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 Leaders.
December 26, 2019

from what I've tried quickly, it seems that list of two Insight Object Beans should work

maybe you are not exactly populating it with insight objects?

here's sample of what's working for me:

import com.onresolve.scriptrunner.runner.customisers.PluginModule 
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade

@WithPlugin("com.riadalabs.jira.plugins.insight")
@PluginModule ObjectFacade objectFacade
@PluginModule ObjectTypeAttributeFacade objectTypeAttributeFacade

/* you get your parent object here somehow */

def objects = parent.objectAttributeBeans.find {
objectTypeAttributeFacade.loadObjectTypeAttributeBean(it.objectTypeAttributeId).name in ["your 1st attribute name", "your 2nd attribute name"]
}?.objectAttributeValueBeans*.referencedObjectBeanId.collect {
objectFacade.loadObjectBean(it)
}

issue.setCustomFieldValue(insightCustomFieldObject, objects)

basically, you get object ids from your attributes and then turn it into proper list of insight objects, with which you update your issue

Jorden Van Bogaert
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 Leaders.
December 26, 2019

Hi @Ilya Turov 

Thanks for your reply again :) I had just finally found what I had been doing wrong. I didn't make use of the "referecedObjectBeanId" so I was consistently having casting issues.

Thanks for the help!

Like Ilya Turov likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events