Syntax errors while executing groovy script for insight objects

Ahmed Trabelsi March 30, 2020

Hi,

I'm trying to execute the following script in order to update insight object attribute

https://documentation.mindville.com/display/ICV60/Update+object+attribute

However, many syntax errors were displayed.

Any idea?

Thanks

Ahmed

2 answers

1 accepted

4 votes
Answer accepted
C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2020

The errors are all static checking errors, which can be ignored. You do need to define "issue" since the code assumes that this variable will be supplied by the caller.

If you are going to use ScriptRunner, there is a better way to bring in the Insight code:

import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.riadalabs.jira.plugins.insight")

Put this code near the head of your routine. You can then import the Insight libraries like any other library. Here is some code sample that I wrote

import com.atlassian.jira.component.ComponentAccessor;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectSchemaFacade;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeFacade;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectTypeAttributeFacade;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade;

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

import com.riadalabs.jira.plugins.insight.services.model.CommentBean;

import com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade;

import com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactory;

//import insight.Insight
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.riadalabs.jira.plugins.insight");

ObjectFacade of = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade);

ObjectSchemaFacade osf = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectSchemaFacade);

ObjectTypeFacade otf = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeFacade);

ObjectTypeAttributeFacade otaf = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectTypeAttributeFacade);

This approach has the advantage that you can eliminate the static type checking errors because you can tell groovy the type of object that you are instantiating. 

Ahmed Trabelsi March 30, 2020

It's working fine :)

Many thanks

Ahmed

0 votes
C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2020

Are you executing this in the Insight Script Console? Can you provide the syntax errors that you see?

JP _AC Bielefeld Leader_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2020

RIght @C_ Derek Fields 

my guess the errors pop up in the ScriptRunner editor.

Best

JP

Ahmed Trabelsi March 30, 2020

You have just to copy paste the script in scriptrunner's script console. Errors are related to insight classes

Regards,

Ahmed

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 30, 2020

There are differences between Insight's script console and ScriptRunner's console. They don't use the same groovy class and they set up the script environment slightly differently. In fact, there appears to be (or have been) a difference between the script console and the automation script runner. This has bitten me in the past. 

You may be right and the code will work in ScriptRunner, but I would expect Mindville's code to have been written and tested in their environment. 

Ahmed Trabelsi March 30, 2020

Any idea how to resolve these issues? Neither Mindville support nor adaptavist can take a look on it, considered as out of scope :(

Thanks

Ahmed

Suggest an answer

Log in or Sign up to answer