Hi
I need to set watchers on create when a single select list custom field value is being selected.
I tried to use "Set a field as a function of other fields" but got errors when tested several options
How can that be done.
Hi Itamar,
It is not very difficult. First of all install Script Runner plugin. This is a powerful plugin which will be helfpful in the future.
To add user to watchers use this:
import com.atlassian.jira.component.ComponentAccessor def watcherManager = ComponentAccessor.getWatcherManager() def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserObject("userid") if (user) watcherManager.startWatching(user, issue.genericValue)
To get value from custom field use this:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "customfield_name" ); log.warn ("value: "+ issue.getCustomFieldValue( customField_name))
Of course you need to be aware that you need to modify this code according to your requirement.
In case of any problem let me know
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Michal
Can you post the full script
If value is so and so, watchers x, x will be inserted?
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.