I am using a post function to set a list of users for an approval step. As they are internal approvers, I do not want the Assignee to approve the ticket.
Below is what I have thus far - apologies for the mess, I'm sure there is a better way. Very basic: Approvers field, get the name of the group of approvers from cf10209, finds the people in that group, and applies it to the Approvers field. This currently works, but it is a full list of everyone in that group - I need help figuring out a way to only gather those users not equal to the issue.assignee...
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.issue.IssueManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()
def issueManager = ComponentAccessor.getIssueManager()
def approversField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Approvers"}
def assignedGroupValue = customFieldManager.getCustomFieldObject("customfield_10209").getValue(issue)
def changeHolder = new DefaultIssueChangeHolder()
def assignee =issue.getAssignee()
def usersInGroup = groupManager.getUsersInGroup(assignedGroupValue)
approversField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(approversField), usersInGroup),changeHolder)
Any help would be appreciated... Everything I find online tells about making changes to the actual group.
Hello @Cary Watkins
You can filter user like this
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()
def approversField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Approvers"}
def assignedGroupValue = customFieldManager.getCustomFieldObject("customfield_10209").getValue(issue)
def changeHolder = new DefaultIssueChangeHolder()
def assignee =issue.getAssignee()
def usersInGroup = groupManager.getUsersInGroup(assignedGroupValue).findAll {!it.equals(assignee)}
approversField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(approversField), usersInGroup),changeHolder)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.
Get Certified! ✍️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.