Hi Team,
I am using Jira Software Data Center v7.12.1 (SEN-L12515805) and JSD Data Center v3.15.1. I have added Script Runner add on.
I want to write a script which can add all the respective groups of the current logged in user to a new custom field of Group Picker type. How do we fetch associated groups of the current user?
Can you please help?
Hello @Ankita Sharma
Here is example to run in script console
import com.atlassian.jira.event.type.EventDispatchOption
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def groupManager = ComponentAccessor.getGroupManager()
def issueManager = ComponentAccessor.getIssueManager()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("multiGroupPicker customfield name")
def issue = issueManager.getIssueObject("TEST-1")
def groupForUser = groupManager.getGroupsForUser(currentUser)
issue.setCustomFieldValue(customField, groupForUser)
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.