While cloning an issue using Script Listener how to get parent issue id in script

Balakumar PG December 23, 2014

When I try to use "issue.summary = 'NEW TASK: ' + sourceIssue.summary" I get the following error message. Any advice that how can I get parent issue id?

subtasksUpdated=false], SingleParameterMethodListenerInvoker{method=public void com.onresolve.scriptrunner.runner.ScriptListener.workflowEvent(com.atlassian.jira.event.issue.IssueEvent), listener=com.onresolve.scriptrunner.runner.ScriptListener@3af167d7}]' from the invoker 'java.lang.RuntimeException: No such property: sourceIssue for class: Script3'

 

Thanks in advance.

/Bala-

2 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2014

Unfortunately that's not going to work when used as a listener, and I can't think of any other way of getting access to it. 

I fixed it in https://jamieechlin.atlassian.net/browse/GRV-590 - LMK if you want a snapshot version to test it.

Balakumar PG December 23, 2014

Hi Jamie Echlin, we are using Jira 6.3.5a#6334, and script runner version 3.0.7, Java 8. Hope this helps a little. And I would like to test the snapshot and please let me know how to get that.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 29, 2014

Sorry for the delay, I will get to this next weekend.

Balakumar PG January 7, 2015

Hi Jamie Echlin, kindly let me know if is there any update on this regards. Thanks and Regards Bala.

Balakumar PG January 27, 2015

Hi Jamie Echlin, any info for this issue. /Bala.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 28, 2015

Sorry, i know you're waiting. Target is to get the release out within 10 days.

Balakumar PG January 29, 2015

Thanks a lot of response. Just asking if is there anything happening on this regards.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2015

3.0.9 has been released now which has this.

Balakumar PG February 16, 2015

Thanks a lot Jamie Echlin. Will give a try and update.

Balakumar PG April 1, 2015

This worked well now. Thanks a lot again.

0 votes
Balakumar PG January 27, 2015

Thanks a lot for very quick response Jamie. I would like to test the snapshot version.

 

It would be of great help for another clarification. Below is the code which I am trying to make it work with Post Function of create transition in workflow. In this I am trying to copy the watchers of an linked issue, but I am not getting the linked issue at all, but when I check the issue after creating it is having the link. I suspect that the post function is triggered before the issue link is created or some other thing which is going on which I could not understand. If you have any input for me kindly let me know. I tested the same script with Script Console with some test issue, that is working.

import com.atlassian.jira.ComponentManager
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)

def componentManager = ComponentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()
def watcherManager = componentManager.getWatcherManager()
def userManager = componentManager.getUserUtil()

//Set the issue id in below so, the script can be tested
//def issue = componentManager.getIssueManager().getIssueObject("TOOL-127")
log.debug "ADDWATCHERS: The script for inheriting all watchers from Bug to Fix while creating Fix for Bug"def watchUsers = {userNames ->

log.debug "inside watch user"
userNames.each {
def user = userManager.getUser(it)
watcherManager.startWatching(user, issue.getGenericValue())
}
}

if(issue != null && issue.getIssueType().name == "Fix") {
log.debug "ADDWATCHERS: FIX ID: " + issue.toString()
issueLinkManager.getInwardLinks(issue.id).each {
issueLink ->
if (issueLink.issueLinkType.getInward() == "is fix of") {
def linkedIssue = issueLink.sourceObject
log.debug "ADDWATCHERS: BUG ID " + linkedIssue.toString()
def bugWatchers = watcherManager.getCurrentWatcherUsernames(linkedIssue)
log.debug "ADDWATCHERS: bug watchers list " +bugWatchers
def fixWatchers = watcherManager.getCurrentWatcherUsernames(issue)
log.debug "ADDWATCHERS: fix watchers list before copying from BUG" +fixWatchers
watchUsers (bugWatchers)
def fixWatchersAfter = watcherManager.getCurrentWatcherUsernames(issue)
log.debug "ADDWATCHERS: fix watchers list after copying from BUG" +fixWatchersAfter
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events