Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

error when extracting information from a grid to a script field

Ignacio Flores April 8, 2021
Hi there! I am using the "TableGridNextGen" plugin.

I want to extract in a script field the data entered in a grid in an issue "X" but I am getting the following error:

Grid ID=11406 data cannot be retrieved: No signature of method: com.idalko.tgng.jira.server.api.GridServiceImpl.readGridData() is applicable for argument types: (java.lang.Long, java.lang.Long, com.atlassian.jira.user.BridgedDirectoryUser, null) values: [202902, 11406, iflores:1, null]

I leave you my complete code:

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.plugin.PluginAccessor

import org.apache.log4j.Logger

// set up logger
Logger log = Logger.getLogger("com.idalko.scripts");

// configuration (update it to match your JIRA settings)
String tgeCustomFieldName = "Pipeline";
String columnNameToSum = "Consultor_Pipe";

// find TGE custom field
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class);
CustomField tgeCustomField = customFieldManager.getCustomFieldObjectByName(tgeCustomFieldName);
Long tgeCustomFieldIdLong = tgeCustomField.getIdAsLong();

// get current user
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getOSGiComponentInstanceOfType(JiraAuthenticationContext.class);
Object userObject = jiraAuthenticationContext.getLoggedInUser();
User user = userObject instanceof ApplicationUser ? ((ApplicationUser) userObject).getDirectoryUser() : (User) userObject

// read the grid data
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor();
Class dataManagerClass = pluginAccessor.getClassLoader().findClass("com.idalko.tgng.jira.server.api.GridService");
//def gridService = ComponentAccessor.getOSGiComponentInstanceOfType(apiServiceClass);
def tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(dataManagerClass);
Set<String> columnNames = new HashSet<String>();
log.warn(tgeGridDataManager)
columnNames.add(columnNameToSum);
Long issueId = issue.getId()
List<Map<String, Object>> gridData = new ArrayList<Map<String, Object>>();
try {
def callResult = tgeGridDataManager.readGridData(issueId, tgeCustomFieldIdLong, user, null);
gridData = callResult.getRows();

log.warn("Grid ID=" + tgeCustomFieldIdLong + " content: " + gridData + "\n");

for (row in gridData) {
def columns = row.getColumns()
// METODO PARA IMRPMIR TODO LO QUE ENCUENTRA EN LA GRILLA SIRVE PARA REVISAR EN LOG

def Consultor = columns.get("Consultor_Pipe")
log.warn("Online: "+Consultor)
}

} catch (Exception e) {
log.warn("Grid ID=" + tgeCustomFieldIdLong + " data cannot be retrieved: " + e.getMessage() + "\n");
}

1 answer

0 votes
Anastasia Dmitrieva
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 9, 2021

Hello Ignacio, 

My name is Anastasiia from iDalko Support team.

This issue is handled as part of the support at the moment.

I will revert back once that the problem is resolved proving the solution!

Anastasiia

Suggest an answer

Log in or Sign up to answer