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

Get the property information of the insight type field in Issue by scriptrunner script

xixi li May 4, 2023

Hi all community members, looking forward to your assistance, thanks.

I expect to achieve the following by way of scriptrunner scripts
1、Get the attribute information value of the Account Full Name field value
2、Get the above attribute information values and then assign each of them to a field

Although I tried to write part of the content, but never succeeded.


import com.atlassian.jira.util.ComponentLocator
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.PluginModule

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.Issue

import com.riadalabs.jira.plugins.insight.services.model.ObjectBean

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

Issue issue
@WithPlugin(value = "com.riadalabs.jira.plugins.insight")
@PluginModule IQLFacade iqlFacade

iqlFacade.findObjects("objectType = Сотрудник")

//定位issue,并获取issue中需要的字段信息
def Issue = Issues.getByKey('PCAP-51').getCustomFieldValue("Account Full Name")

//获取该字段内的属性信息

log.info("Get Technical Group from insight object")
Class objFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().loadClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def rtObj = ComponentAccessor.getOSGiComponentInstanceOfType(objFacadeClass)
def cfManager = ComponentAccessor.getCustomFieldManager()

//final tgId = 937

def incidentAssetCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11400)
def incidentAssetValue = issue.getCustomFieldValue(incidentAssetCf)

def rtObjAttr = rtObj.loadObjectAttributeBean().getObjectAttributeValueBeans()

def tgVal = rtObjAttr.first().value

log.info("Technical Group value is: $tgVal")

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events