Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

[Jira5.1] How to update group select field?

Mathias Buchholz September 27, 2012

I have read thatsolved answer

https://answers.atlassian.com/questions/38549/how-to-set-a-group-picker-customfield-in-a-post-function/38581

i am missing: which library do i have to import for 'Group'. I wrote following lines:

CustomField watcherField = customFieldManager.getCustomFieldObjectByName( "customfield_10702" )
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
Group watcherGroup = componentManager.getUserUtil().getGroup("HWSWBeobachter")

customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(watcherField),watcherGroup),changeHolder);
customField.store()

I hab two errors:

  • NullPointerException --> I expect the group wasnt found ?
  • javax.script.ScriptException: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.crowd.embedded.impl.ImmutableGroup@1d1792c4' with class 'com.atlassian.crowd.embedded.impl.ImmutableGroup' to class 'com.atlassian.gadgets.opensocial.model.Group'

How can i get the user and usergroup list?

thank you

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Mathias Buchholz September 27, 2012

meanwhile problems is solved step-by-step witch the the answer questions.

Sooo: how to set the question solved itself ?

1 vote
Mathias Buchholz September 27, 2012

Solution was easier than expected.

I should send a collection instead of an object

List<Group> groupList = new ArrayList<Group>()
groupList.add(watcherGroup)
orderableField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(orderableField),groupList),changeHolder);

0 votes
Mathias Buchholz September 27, 2012

Solution was easier than expected.

I should send a collection instead of an object

List<Group> groupList = new ArrayList<Group>()
groupList.add(watcherGroup)
orderableField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(orderableField),groupList),changeHolder);

0 votes
Mathias Buchholz September 27, 2012

meanwhile i found how to get user and usergroup.

import com.atlassian.crowd.embedded.api.Group

Group watcherGroup = componentManager.getUserUtil().getGroupObject("HWSWBeobachter")
OrderableField orderableField = componentManager.getFieldManager().getOrderableField("customfield_10702")
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
orderableField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(orderableField),watcherGroup),changeHolder);

I received some exceptions:
from the log:

[onresolve.jira.groovy.GroovyRunner] The script failed : javax.script.ScriptException: javax.script.ScriptException: java.lang.ClassCastException: com.atlassian.crowd.embedded.impl.ImmutableGroup cannot be cast to java.util.Collection
[onresolve.jira.groovy.GroovyFunctionPlugin] Error executing post-function
javax.script.ScriptException: javax.script.ScriptException: java.lang.ClassCastException: com.atlassian.crowd.embedded.impl.ImmutableGroup cannot be cast to java.util.Collection

is there a missing cast?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events