I have a table grid with two columns (column A and column
and it's initialized with static values (no datasource). The values in column B are set to "Not Validated", but it has a checkbox to enable editing it to "Validated". And my script validator is in the "Validate" transition in the workflow.
So the scenario must be like this: when all values in column B are ticked to "Validated", and when the workflow's transition "Validate" is clicked, it must check whether all values in column B are all "Validated" before the workflow can transition to "Validated" status.
However, I'm encountering a problem with reading the table grid. I'm getting the correct issue and custom field id but it's returning an empty data. So since my validator can't read the grid data, it's not checking anything.

Do you know what might be the issue?
--------------------------------------------------------------------------------------------------
Here is snippet of my code:
@WithPlugin("com.idalko.jira.plugins.igrid.api.data.TGEGridTableDataManager")
@PluginModule
TGEGridTableDataManager tgeGridDataManager
@WithPlugin("com.idalko.jira.plugins.igrid.api.config.grid.TGEGridConfigManager")
@PluginModule
TGEGridConfigManager tgeConfigManager
// get an issue
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class);
Issue issue = issueManager.getIssueObject("TEST-1");
log.info("issue: " + issue);
// find the TGE custom field
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class);
CustomField tgeCustomField = customFieldManager.getCustomFieldObject(10710);
log.info("custom field: " + tgeCustomField);
// get current user
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getOSGiComponentInstanceOfType(JiraAuthenticationContext.class);
Object userObject = jiraAuthenticationContext.getLoggedInUser();
User user = userObject instanceof ApplicationUser ? ((ApplicationUser) userObject).getDirectoryUser() : (User) userObject;
// get TGE custom field
Long tgeCustomFieldId = tgeCustomField.getIdAsLong();
// read the data from the first grid
tgeGridDataManager = ComponentAccessor.getOSGiComponentInstanceOfType(TGEGridTableDataManager.class);
def rows = tgeGridDataManager.readGridData(issue.getId(), tgeCustomFieldId, null, null, 0, 10, user);
def values = rows.getValues()
StringBuilder returnResult = new StringBuilder();
returnResult.append("Grid rows: " + values + "\n");
if (!values.isEmpty()) {
rows = tgeGridDataManager.readGridData(issue.getId(), tgeCustomFieldId, null, null, 0, 10, user);
values = rows.getValues()
returnResult.append("Grid content: " + values + "\n");
} else {
rows = tgeGridDataManager.readGridData(issue.getId(), tgeCustomFieldId, null, null, 0, 10, user);
values = rows.getValues()
String msg = returnResult.append("Grid ID: " + tgeCustomFieldId + " content: " + values + "\n");
invalidInputException = new InvalidInputException(msg)
throw invalidInputException;
// check if any row has an 'Not Validated' status selected
for (int rowNumber = 0; rowNumber < values.get(values.size()); rowNumber++) {
Map<String, Object> rowData = values.get(values.size()).get(rowNumber);
Map<String, Object> status = rowData.get(
"validate" // name of the column from TGE configuration
);
String statusName = status.get(
"Not Validated" // pre-defined property for 'list', 'userlist', 'radio' column types
);
if ("Not Validated" // name of the status I want to forbid
.equals(statusName)) {
// throw an exception with the field ID and an error message for TGE field
// it will prevent transition with the noted error, user will stay on the transition screen
invalidInputException = new InvalidInputException(tgeCustomFieldId, "Row #" + (rowNumber + 1) + " of TGE grid has an 'Open' status selected");
throw invalidInputException;
}
}
}
println(returnResult.toString());
return returnResult.toString();