I have written this so far to try to create a subtask for each user in a customfield with the help of this other issue.
workflow post-function: creating subtask for each user of group
@Jamie Echlin [Adaptavist] this was originally your solution I followed.
I keep getting an error that says:
/secure/WorkflowUIDispatcher.jspa [groovy.canned.utils.ConditionUtils] javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: ArrayList_delegateProxy.getUsers() is applicable for argument types: () values: []
Possible solutions: getClass(), getName(), every()
Any ideas what I am missing here?
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.crowd.embedded.api.Group;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.SubTaskManager
import org.ofbiz.core.entity.GenericValue
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
def issueFactory = componentManager.getIssueFactory()
def issueManager = componentManager.getIssueManager()
def indexManager = componentManager.getIndexManager()
def groupCf = customFieldManager.getCustomFieldObjectByName("Reviewers") // name of group CF
Group group = issue.getCustomFieldValue(groupCf) as Group
if (group) {
group.getUsers().each {String user ->
MutableIssue newIssue = issueFactory.getIssue()
newIssue.summary = "Doc ERB Assessment for $user"
newIssue.issueTypeId = '12600'
newIssue.project = issue.project
newIssue.assignee = UserUtils.getUser(user)
newIssue.assigneeId = user
Map<String,Object> newIssueParams = ["issue":newIssue] as Map<String,Object>
def currentUser = componentManager.getJiraAuthenticationContext().getUser()
GenericValue newIssueGv = issueManager.createIssue(currentUser, newIssueParams)
indexManager.reIndex(newIssueGv);
SubTaskManager subTaskManager = componentManager.getSubTaskManager()
subTaskManager.createSubTaskIssueLink(issue, newIssue, componentManager.getJiraAuthenticationContext().getUser())
}
}