You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JIRA Insight Groovy脚本调用findObjectInboundReferencedBeans方法报错问询

问题原因
  • API方法签名不匹配:你当前使用的Insight版本中,findObjectInboundReferencedBeans方法不支持仅传入单个int类型的对象ID参数,该方法实际要求传入两个参数,第二个参数为布尔值,用于指定是否加载引用对象的属性值,你只传入了一个ID参数,因此触发方法签名不匹配的报错。
  • 调用路径冗余:你已经通过objectFacade.loadObjectBean()拿到了目标Agreement对应的ObjectBean实例,不需要再调用Facade层接口获取入站引用,直接调用实例方法即可完成需求。
正确实现方案

方案1:修复原方法调用

补全方法要求的第二个参数即可正常运行:

// 第二个参数传true加载关联对象的所有属性,传false仅返回基础对象信息
def inRef = objectFacade.findObjectInboundReferencedBeans(objectId, true)

方案2:直接通过ObjectBean实例获取(更推荐,兼容性和性能更优)

直接调用已获取的insightObject实例的入站引用方法,还可以直接过滤得到你需要的Services关联对象列表:

// 获取所有入站引用,过滤出名为Services的引用,提取对应的关联对象
def serviceList = insightObject.getInboundReferences()
                               .findAll { it.getObjectTypeAttributeBean().getName() == "Services" }
                               .collect { it.getObjectBean() }
// 后续可以直接遍历serviceList操作对应的Services对象
完整修改参考

替换你脚本中问题段的代码即可:

import com.atlassian.jira.component.ComponentAccessor;
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean;
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean;
import com.riadalabs.jira.plugins.insight.services.model.MutableObjectAttributeBean;
import com.riadalabs.jira.plugins.insight.services.model.MutableObjectBean;

Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)

def attributeRef = "Status smlouvy"

def objectKey = object.getObjectKey();
def insightObject = objectFacade.loadObjectBean(objectKey)
int objectId = insightObject.getId()

// 替换原有问题代码
def serviceList = insightObject.getInboundReferences()
                               .findAll { it.getObjectTypeAttributeBean().getName() == "Services" }
                               .collect { it.getObjectBean() }

def objectAttribute = objectFacade.loadObjectAttributeBean(objectId, attributeRef)
def objectAttributeValue = objectAttribute.getObjectAttributeValueBeans()[0].getValue()

log.warn(objectKey.toString())
log.warn(insightObject.toString())
log.warn(serviceList)

内容的提问来源于stack exchange,提问作者Jiri Kofron

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 20:18:04