Update Column of Table Grid Next Generation not working - script runner

Nannette Mori May 4, 2023

Script Runner Version 7.8.0

Table Grid Next Generation 1.13.8-jira89

I created a listener to fire on Issue.Updated to have the columns of my grid updated with the values of jira customfields when the user updates those jira customfields 

 

 

Per documentation on Get GridService

PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor()

Class apiServiceClass = pluginAccessor.getClassLoader().findClass ("com.idalko.tgng.jira.servier.api.Gridservice")

I get the error when using .findClass (cannot find mathing method java.lang.Object#call(java.lang.string) 

if I use -Class apiServiceClass = pluginAccessor.getClassLoader().loadClass("com.idalko.tgng.jira.servier.api.Gridservice" ("com.idalko.tgng.jira.server.api.Gridservice") the error goes away

This is the same behavior for get GridRow Class I get the error if I use .findClass

Class gridRowClass = pluginAccessor.getClassLoader().loadClass("com.idalko.tgng.jira.servier.api.Gridservice" ("com.idalko.tgng.jira.servrt.api.GridRow")

So When I am defining Read field Data

def fieldData = gridService.readFieldData (readFieldData is not available?)

How do I fix this?

Also the example I reviewed is getting the field data for a specific issue, I need to get the issue Id for each issue

Below is how I am getting the issue id

def issue = event.getIssue()

IssueManager issueManager = getOSGiComponentInstanceofType(ustomfieldManager.class)

Long issueID = issue.getId()

 

I tried using

IssueManager issueManager = getOSGiComponentInstanceofType(ustomfieldManager.class)

Issue issue = issueManager.getIssueObject()

Long issueID = issue.getId()

it doesn't like Issue issue = issueManager.getIssueObject()

What is the correct way to get the issue ID for a listener that is accessing and updating Table Grid Data

Is using Update Rows the correct code to update a column from a Jira Customfield?

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 4, 2023

Hi @Nannette Mori

From your description, it appears you are trying to invoke APIs from other third-party libraries.

Have you tried using the @WithPlugin and @PluginModule annotations as shown in this ScriptRunner Documentation?

These annotations will help you to bypass the pluginAccessor.getClassLoader().loadClass class invocation step.

To invoke the class from the idalko package, you will need to use:-

import com.idalko.tgng.jira.servier.api.*


@WithPlugin ("com.idalko.tgng.jira.servier.api")

@PluginModule
GridService gridService

@PluginModule
GridRow gridRow

Once you have made this declaration, you can invoke the methods using the gridService and gridRow object references, respectively.

Also, why are you using this approach:

IssueManager issueManager = getOSGiComponentInstanceofType(ustomfieldManager.class)

to invoke the IssueManager?

Firstly, there is no class called ustomfieldManager.class. This is a typo error which will result in a compilation error. It is the CustomFieldManager, which is unrelated to the Issue Manager.

To invoke the IssueManager, you just have to ComponentAccessor as shown below:-

import com.atlassian.jira.component.ComponentAccessor
...
...
...

def issueManager = ComponentAccessor.issueManager

And, to invoke the CustomFieldManager object, you need to use:

import com.atlassian.jira.ComponentAccessor
...
...
...
def customFieldManager = ComponentAccessor.customFieldManager

I hope this helps to answer your question. :-)

Thank you and Kind regards,

Ram

Nannette Mori May 5, 2023

Thank You for responding

I am getting a compile  error using 

//Grid Service

@WithPlugin (com.idalko.tgng.jira.server.api")

@PluginModule

GridService gridService

@PluginModule

GridRow gridRow

I am importing the com.idalko.tgng.jira.server.api.*

The error is : General error during conversion com.idalko.tgng.jira.server.api was not installed/enabled

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2023

Hi @Nannette Mori

I ran a quick test in my environment and installed the latest release of the Idalko Table Grid Next Generation, and it appears there is a difference in the app key.

So when invoking the iDalko plugin via ScriptRunners @WithPlugin annotation, it needs to be invoked as

@WithPlugin (value = 'tge.cloud')

To identify what is the correct value that should be used for the @WithPlugin annotation, go to the plugin and locate the App key as shown in the screenshot below:-

image_2023-05-08_201311494.png

The screenshot above shows that the  App key used by the Table Grid Next Generation plugin is tge.cloud.

Below is the sample code that I have tested with:-

import com.onresolve.scriptrunner.runner.customisers.PluginModule

import com.onresolve.scriptrunner.runner.customisers.WithPlugin

import com.idalko.tgng.jira.server.api.GridService

@WithPlugin(value = 'tge.cloud')

@PluginModule

GridService gridService

def loggedInUser = Users.loggedInUser

gridService.addRows(2, 2, loggedInUser, [])

Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the configuration:-

withPlugin.png

I hope this helps to answer your question. :-)

Thank you and Kind regards,

Ram

Nannette Mori May 9, 2023

Ram,

 

Thank You for your assistance!!! Your solution worked!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.4.3
TAGS
AUG Leaders

Atlassian Community Events