I'm trying to copy the labels from a parent issue to a subtask on creation using a scriptrunner Post Function.
I'm doing the same for the compinents and Due Date fields which is working fine.
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.label.LabelManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.label.Label;
import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.issue.issuetype.IssueType;
import java.sql.Timestamp;
ComponentManager componentManager = ComponentManager.getInstance();
IssueType issueType = issue.getIssueTypeObject();
if(issueType.isSubTask()) { // Only do this for subtasks
Issue parent = issue.getParentObject();
/**
* LABELS
*/
Set<Label> labels = parent.getLabels();
issue.SetLabels(labels);
}Above code throws this error:
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.IssueImpl.SetLabels() is applicable for argument types: (java.util.Collections$UnmodifiableSet)
Apparently I'm getting an Unmodifiable Collection from the parent
things I tried so far:
Creating a new Set which throws the following:
No signature of method: com.atlassian.jira.issue.IssueImpl.SetLabels() is applicable for argument types: (java.util.HashSet)
Strange because HashSet is an implementation of Set right? Can't create a new Set of course.
- Getting the parent as MutableIssue. => Same problem, still getting an Unmodifiable Set
- Using the LabelManager's setLabel. => Need the issue ID in the arguments which doesn't exist yet
Any ideas how to solve this? This is JIra 6.4.12