Post function to add user to watcher list in jira 5.2.5

Can anyone help me with a code for the post function to add the user in the watcher list in jira.

i'm using jira 5.2.5. ?

3 answers

1 accepted

Accepted Answer
0 votes

can you give us a screen shot how you are adding postfunction to your workflow?

The Problem is solved now.

here we are adding the configured user to the watcher list based on the configured project and configure supplier (custom field).

The problem was with module where we are checking the configure supplier is equal to the issue supplier.

Hi,

You can use JJupin plugin to make your work easier. To add the user to watchers, you can do it in 3 lines of SIL code:

if (arrayElementExists(watchers, currentUser()) == false) {
    watchers = arrayAddElement(watchers, currentUser());
}

Yes, that's all! You can read more about JJupin here: http://confluence.kepler-rominfo.com/display/JJUPIN/JJupin+Documentation+%28v+2.5.x+and+v+2.6.x%29

Regards,

Silviu

Thank you so much.

But i need the java code.

I think that it is way easier to use existing plugins instead of rolling your own and reinvent the wheel. Also, you get a lot of flexibility with JJupin, there are a lot of things simplified to meet user/administrator needs.

Instead of currentUser(), is there a variable for adding the component lead? I see that you can set "complead" using admAddProjectComponent - but I don't see it listed on the page here: http://confluence.kepler-rominfo.com/display/SIL/Variable+Resolution

following code worked for us

WatcherManager wm = ComponentAccessor.getWatcherManager();
wm.startWatching(user, issue);

following code what we used in our jira 5.0

private UserAssociationStore userAssociationStore = ComponentManager.getComponentInstanceOfType(UserAssociationStore.class);
public static final String ASSOCIATION_TYPE = "WatchIssue";
userAssociationStore.createAssociation(ASSOCIATION_TYPE,user, issue.getGenericValue());

Thank you so much.

i used the same code but when i build the post function plugin it is not working.

Do i need to make any changes in jira before adding user to watcher list.

i used the same code.

but its not working for me in jira 5.2.5. The user is not adding to the watcher list.

Please help.

check my answers, i have updated!!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

204 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