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

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 vote

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.

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.

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

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

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

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

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

3.0.9 has been released now which has this.

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

This worked well now. Thanks a lot again.

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

180 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you