Hello,
I'm working on Insight automation groovy script, but I got stuck in one point.
I have Insight object called "Agreement".
This object has Inbound Refrences called "Services".
Each Agreement can have any number of Services. I need to get list of all Services for any Agreement. I found the method findObjectInboundReferencedBeans(int id) in the docs, but apparently, I'm missing something as when I run the script, I get an error in log:
AutomationRuleGroovyScriptAction, Unexpected error: No signature of method: com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl.findObjectInboundReferencedBeans() is applicable for argument types: (java.lang.Integer) values: [15748]
Here is my script:
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 agreementStatusId = 2641
// def serviceStatusId = 2180
// def activeStatus = 1
// def stoppedStatus = 6
def attributeRef = "Status smlouvy"
def objectKey = object.getObjectKey();
def insightObject = objectFacade.loadObjectBean(objectKey)
int objectId = insightObject.getId()
----------------------------------
// Here is the line I need help with
def inRef = objectFacade.findObjectInboundReferencedBeans(objectId)
----------------------------------
def objectAttribute = objectFacade.loadObjectAttributeBean(objectId, attributeRef)
def objectAttributeValue = objectAttribute.getObjectAttributeValueBeans()[0].getValue()
log.warn(objectKey.toString())
log.warn(insightObject.toString())
log.warn(inRef)
I use this script also to get attribute value from Agreement object, which works fine.
I guess the problem is that I call the method on wrong object, but when I try to call in dirrectly on "insightObject" , I got the same error.
Thank you!
I have the exact same error. I displayed all the methods of the ObjectFacadeImpl Class and it seems the findObjectInboundReferencedBeans method is just missing for some reason:
2021-10-18 17:40:46,980 DEBUG [groovy.script]: Class: com.riadalabs.jira.plugins.insight.channel.external.api.facade.impl.ObjectFacadeImpl
2021-10-18 17:40:46,980 DEBUG [groovy.script]: Method: [equals, getClass, hashCode, notify, notifyAll, toString, wait, addAttachmentBean, countObjectBeans, createWatcherBean, deleteAttachmentBean, deleteCommentBean, deleteObjectAttributeBean, deleteObjectBean, deleteWatcherBean, findAttachmentBeans, findCommentBeans, findObjectAttributeBeans, findObjectHistoryBean, findObjectTicketConnections, findWatcherBeans, loadAttachmentBeanById, loadCommentBean, loadObjectAttributeBean, loadObjectBean, loadWatcherBean, moveObjects, storeCommentBean, storeObjectAttributeBean, storeObjectBean, storeObjectBeanIgnoreAttributeValidation, validateObjectAttributeBean, validateObjectBean]
I would really need this method for some scripts to work properly, hopefully someone finds a fix for it.
Hi Alexander, that is interesting! I didn't though about the method can be missing! I found Insight documentation rather confusing and this is even more strange. I was thinking that I'm probably using wrong class. Thank you very much, I might be good idea to contact Insight developers to clarify this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Jiří!
Yup same for me, i already opened a case with Atlassian. I will post updates here once i know more.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Jiří!
I got an update from Atlassian. The method was removed with the release of Insight 5.1, see the upgrade notes here.
However, you can just use this to solve your issue:
def inRef = iqlFacade.findObjects(/object HAVING outboundReferences(Key = ${objectKey})/)
Hope this helped!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
you are hero! :) I will check this solution, but as it is recommended by Atlassian themselves, so it should work. Accepted your answer and thank you very much!
EDIT: Hey, it works like a charm! Thanks a lot once again!
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.