Set a multi group picker custom field via a post function
Problem:
If you want to set a "Group Picker (multiple groups)" with a post-function.
If a "customer" makes a new Task, the Group Picker "Security Level Group" should be automatically filled with the existing Group "customer".
the following if/else works, and I can set the Description depending on customer yes/no, but i have no Chance to set the customer-group into my userSecGrp.
I also did not find anything in the Internet that could help me.
def userSecGrp = customFieldManager.getCustomFieldObjectByName("Security Level Group") def groupManager = ComponentAccessor.getGroupManager() if (groupManager.isUserInGroup(issue.reporter?.name, 'customer') ) { issue.setDescription("A generated description for extern customer") def group = groupManager.getGroup("customer") def groupObj = groupManager.getGroupObject('customer') // issue.setCustomFieldValue(userSecGrp, group) //issue.setCustomFieldValue(userSecGrp, group) //issue.setCustomFieldValue(userSecGrp, groupManager.getGroupObject('customer')) //issue.setCustomFieldValue(userSecGrp, userUtil.getUserByName("eninaus")) } else { // system fields issue.setDescription("A generated description for non-customer") }
If i activate one of the setCustomFieldValue, I only get the message that something is not compatible to my jira Version.
So the question is: How to setCustomFieldValue for a Group Picker to a Group? or GroupObject...
Thx for your support
Solution
The following code works for me to set the value of single and multigroup custom fields:
import com.atlassian.jira.component.ComponentAccessor def customFieldManager = ComponentAccessor.getCustomFieldManager() def groupManager = ComponentAccessor.getGroupManager() def multiGroupCf = customFieldManager.getCustomFieldObjectByName("multigrouppicker") def singleGroupCf = customFieldManager.getCustomFieldObjectByName("GroupPicker") def group = groupManager.getGroup("jira-developers") issue.setCustomFieldValue(multiGroupCf, [group]) issue.setCustomFieldValue(singleGroupCf, [group])
Related articles