Insight IQLFacade scripts works in Insight Script Console, but not work in Exalate script

Hi everyone,

I’m searching Insight objects using IQL, the code as the following:

Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade")
def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass)

def insightObjectName = "My Object"
def objects = iqlFacade.findObjectsByIQLAndSchema(2, "Name = \"" + insightObjectName + "\"")

This code works if I run it from Insight Script Console, and it returns a list with My Object inside.
But when I paste it to the Exalate incoming script, it does not work anymore.

So what is the problem here?
Thank you very much!

STATUS UPDATED

I tried to do a loadObjectBean from both sides.
The object is loaded successfully from Insight Script Console.
On the Exalate side, it threw an Exception PermissionInsightException: Anonymous User., so I think the problem here related to Permission.
So does anyone know how to fix this?

def object = objectFacade.loadObjectBean("IFI-116")

As always, I want to save the solution as a reference for the future.

I fixed it by set current logged in user to a user who has permission to browser Insight objects:

def authContext = ComponentAccessor.getJiraAuthenticationContext();
def currentUser = ComponentAccessor.getUserManager().getUser("admin")
authContext.setLoggedInUser(currentUser);
2 Likes

When I use authContext in the scripted field, all the transitions done by a Jira user is attributed to the admin id.

import com.atlassian.jira.component.ComponentAccessor
def authContext = ComponentAccessor.getJiraAuthenticationContext()
def currentUser = ComponentAccessor.getUserManager().getUser(“admin”)
authContext.setLoggedInUser(currentUser)
return issue.getCustomFieldValue(30020)[0].getReference(‘Attribute’).getName()

Hi @nhac.tat.nguyen ,

Hope you are doing well.

I was actually trying this out to sync a default value for an insight object in Exalate and was unable to do so although I feel I am close.

This is where I am currently :

def authContext = ComponentAccessor.getJiraAuthenticationContext();
def currentUser = ComponentAccessor.getUserManager().getUser(“admin”)
authContext.setLoggedInUser(currentUser);
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass(“com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade”);
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
def insightObjectName = “InsightField”
def object = objectFacade.loadObjectBean(“IT-4”)

I get an error
Exalate has problems performing an issue update in this Jira. Details: java.lang.String cannot be cast to java.util.Collection

Do you have any idea how to resolve this?

1 Like