In a particular transition I change the assignee from developer to QA responsible, but would like to add the developer as watcher so he is still in the loop of his code.
I therefore would need a post function (script), that adds the previous assignee to the list of watchers.
Hoe can I do this?
Hi,
As I understand, you want to add to watchers list the last assignee before changing it on the post-function of a transition, right?
Adding this script just before the "change assignee" step of the post-function and it should work:
import com.atlassian.jira.component.ComponentAccessor
def watcherManager = ComponentAccessor.watcherManager
def userManager = ComponentAccessor.userUtil
def user = issue.getAssignee()
watcherManager.startWatching(user, issue)
Hope it helps.
Regards,
Marcos
Hi Marcos, I copy/pasted your suggested script, but it does not run. see attached JPG
Best - Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Marcos Sanchez ,
please can you help me how the script should look like if I need to add all users from a specified user role to Watchers?
Thanks!
Roman Bliznak
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you access to JIRA log? Maybe there will be more information about the transition execution and it could be something valuable.
Anyway, I've checked on my Jira and it works fine to me. I attach a screenshot of my configuration (same as yours).
Sincerely, I don't know why it doesn't works to you, configuration is fine...
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcos
I do not have access to the JIRA log, so I have to wait for out IT support, which I can contact personally early next week.
Please keep the ticket open until I come back
Thanks and best regards
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcos
I found the error - I tested with a project, where the modified workflow was not assigned - too stupid !!
Your script works perfect.
Thanks again and please excuse the trouble you had with me :-(
Please close the ticket.
Best regards
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Hahahaha don't worry!!
To close it, accept the first answer ;)
Regards!
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
It's not a script problem (as message says), so if you add it to the post-function and test it, it should work.
I recomment you to use a test environment or workflow to try it if you have one before implementing it to production.
Try it and tell me if it works.
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcos
I did what you told me and created a new (first) post function with the script. See attached screen shot. If not this way, how shall I add your script?
Thanks again and best regards
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This configuration of the screenshot is fine.
I've just told you that the error that you get in the first screenshot is not a code error.
Did you tried to do the transtion and check if that all works?
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good morning Marcos
Yes, I added the script to the JIRA test instance and processed through the workflow. As you can see in my last screen shot, the post function says: "Has not run yet", so it did not process and I do not know why not.
Best regards
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is the workflow correctly published?
I know that this question can be obvious but is just for checking.
Regards,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcos
Yes, the workflow is published. I re-tested, added myself as reporter and assignee, removed all watchers and processed the issue through the workflow. In the transition, where the assignee is changed, I am not added as watcher. And the post function still says: "Has not run yet", so somehow it does not start.
Best regards
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.