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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,788 views 11 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot