// This script adds two rows to Grid custom field with default configuration
// named "API Sample" in issue TEST-1
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.plugin.PluginAccessor
import com.atlassian.jira.user.ApplicationUser
// Get issue id
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class)
Issue issue = issueManager.getIssueObject("TEST-1")
Long issueId = issue.getId()
// Get TGNG custom field id
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class)
CustomField tgngCustomField = customFieldManager.getCustomFieldObjectsByName("API Sample").get(0)
Long tgngCustomFieldId = tgngCustomField.getIdAsLong()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get GridService
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor()
Class apiServiceClass = pluginAccessor.getClassLoader().findClass("com.idalko.tgng.jira.server.api.GridService")
def gridService = ComponentAccessor.getOSGiComponentInstanceOfType(apiServiceClass)
// Add a row
// Only "key" is required for userlist columns
gridService.addRows(issueId, tgngCustomFieldId, user, [
["jsummary": "Buy groceries", "jassignee": ["key": user.getKey()], "jstatus": "Open"],
["jsummary": "Plan vacation", "jassignee": ["key": user.getKey()], "jstatus": "In Progress"]
]) |