Hi ,
I'm trying to insert the row into Table Grid next generation (1.13.1-jre8) through behaviour script through server side script.
Following is the behaviour script:
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.transform.BaseScript
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.api.User
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.jira.security.JiraAuthenticationContext
import com.atlassian.plugin.PluginAccessor
import com.atlassian.jira.user.ApplicationUser
def actions
def ata = getFieldByName("Park No").getValue() as String
def jta = getFieldByName("TSK").getValue() as String
Issue issue = issue
if (ata) {
def httpBuilder1 = new HTTPBuilder("http://localhost:8080/")
httpBuilder1.ignoreSSLIssues()
if(jta){
actions = httpBuilder1.request(Method.GET, ContentType.JSON) {
uri.path = "rest/scriptrunner/latest/custom/fetchdetail"
uri.query = [query:"$ata/$jta"]
//headers."User-Agent" = "My JIRA"
response.failure = { resp, reader ->
log.warn("Failed to query GitHub API: " + reader.text)
}
}
}else{
actions = httpBuilder1.request(Method.GET, ContentType.JSON) {
uri.path = "rest/scriptrunner/latest/custom/fetchdetail"
uri.query = [query:"$ata"]
//headers."User-Agent" = "My JIRA"
response.failure = { resp, reader ->
log.warn("Failed to query GitHub API: " + reader.text)
}
}
}
// get an issue
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class);
Long issueId = issue.getId()
// Get TGNG custom field id
CustomFieldManager customFieldManager = ComponentAccessor.getOSGiComponentInstanceOfType(CustomFieldManager.class)
CustomField tgngCustomField = customFieldManager.getCustomFieldObjectsByName("Park Details").get(0)
Long tgngCustomFieldId = tgngCustomField.getIdAsLong()
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Get GridService
PluginAccessor pluginAccessor = ComponentAccessor.getPluginAccessor()
Class apiServiceClass = pluginAccessor.getClassLoader().loadClass("com.idalko.tgng.jira.server.api.GridService")
def gridService = ComponentAccessor.getOSGiComponentInstanceOfType(apiServiceClass)
try {
gridService.addRows(issueId, tgngCustomFieldId, user, [
["ParkDetailGrid_ParkName": "Buy groceries", "ParkDetails_Description":"Test1"],
["ParkDetailGrid_ParkName": "Plan vacation", "ParkDetails_Description":"Test2"] ]
)
} catch (Exception e) {
}
}
Getting following error:
[c.o.jira.behaviours.BehaviourManagerImpl] Found class null but could not find method run
groovy.lang.MissingPropertyException: No such property: issue for class:
What change should I make so that Behaviour script can be executed on value change in TSK or ParkNo field
Any updates on your request?
I have similar question.. maybe Table Grid Next Generation just can't work with Behaviors??
Since this case is not created hence there issue object is null and there is current ID created. that's why row insert is failing. if we use old case id then it is updating the old case or pre-exist case. my requirement to add row in current issue table grid. Can some one help on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.