want to set a "Group Picker (multiple groups)" with a post-function. Maybe you can give me a hint...
{
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("xy")) }
{
system fields issue.setDescription("A generated description for non-customer")
}
Community moderators have prevented the ability to post new answers.
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])
You get the error you're receiving when passing a single group, rather than a collection.
Hi,
I try to set an MultiGroupPicker custom field with multiple groups. The setting with 'setCustomFieldValue' works fine.
... List<Group> accessGroups = (List<Group>) mutableIssue.getCustomFieldValue(multiGroupCf); if(accessGroups != null) { accessGroups.add(groupManager.getGroupObject(it)); //set custom field mutableIssue.setCustomFieldValue(multiGroupCf, [accessGroups]); } ...
But if I update the issue with
ComponentAccessor.getIssueManager().updateIssue(currentUser, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);
I get the following error
... java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.atlassian.crowd.embedded.api.Group ...
Maybe you ca help me with this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A thousand thanks!
the "[ ]" was the missing thing in my code.
now it work's for me!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.