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.
×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!
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.