Hi to all,
in a cascading custom field (opening mask) is contained one or more email of jira user. Is it possible, to add all the users contained in the second field of cascading as whatchers of a ticket via script post function?
I believe that from the email it is necessary to extract the user code before adding it as a watcher.
Many thanks! Regards,
Domenico
Hi Domenico!
Here is a way that worked in my instance:
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfValue = customFieldManager.getCustomFieldObjectsByName("CascadingSelect")[0].getValue(issue)
def addresses = cfValue.get(null)?.childOptions*.value
def watcherManager = ComponentAccessor.getWatcherManager()
def userSearcherService = ComponentAccessor.getComponent(UserSearchService)
def theUser
for (def i = 0; i < addresses.size(); i++) {
theUser = userSearcherService.findUsersByEmail(addresses[i])
// Using theUser[0] because the User is an ArrayList of a single ApplicationUser
watcherManager.startWatching(theUser[0], issue)
}
You'll just need to change the name of the Cascading Select field to the name that matches the one in your instance.
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.