Script runner clone issue function - add watcher in target issue

Tarun Sapra Community Champion Jul 30, 2014

Hi All,

I am struggling to add watcher to an issue, the problem here is that

def user = userManager.getUserObject("userid") 
if (user) watcherManager.startWatching(user, issue)

the above snippet works fine if it's placed in the post-function of the "issue", but what i am trying to achieve is that I am trying to clone an issue using script runner and during that process I am trying to add the assignee of the original issue as a watcher in the issue to be cloned and all this is in the post-function of the original issue thus while logging i get the error

[jira.issue.watchers.DefaultWatcherManager] You must specify an issue.

As I understand the above error is because the issue to be cloned as not yet been created and I am trying to add a watcher to it but is there another way to fix this problem apart from wirting a post-funciton in the cloned issue
Thanks!

1 answer

1 accepted

This widget could not be displayed.

I feel like I may be overlooking something obvious with my answer, but I'm not sure what it is. At some point in your post-function, the issue is, in fact, created, right? So why not add the previous assignee as a watcher with code similar to the above after the clone is alive and well and before the post-function completes?

Tarun Sapra Community Champion Jul 31, 2014

Hi Tanner,

I don't think the target issue(issue to be cloned) is created in the post-function as the whole point of using the post function is to create the issue itself, and once the post-fcuntion executes only then the target issue is created.

I think I know what I missed now. You're using a pre-existing script to clone. I was under the impression that you had already authored your own code to do the cloning. Why not take that pre-existing code, modifying it a bit to fit your needs, and then using as your own custom post-function?

Tarun Sapra Community Champion Aug 03, 2014

Actually I was looking for a way to avoid custom code, as in a Large and complex jira instance, custom code sometimes add to maintenance woes of admins/developers

yep. it can be a headache sometimes.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 4 hours ago in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

18 views 0 1
Join discussion

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