Reputation: 470
I am using the the Jira plugin, groovyrunner, which has several built in scripts. One of which is a script listener which runs a built-in script when a certain project fires a specific event. In this case, the script is 'Create a sub-task'. You can run additional code after you select a few settings and possibly constraints. I have it so the assignee is set when the sub-task is created. Now what I want to do is set the component for the sub-task. Currently, it uses the the parent components, which I don't want.
Originally I was trying to use:
issue.setComponentIds('idnum')
but now I just found this:
setComponentObjects(Collection<ProjectComponent> components)
at http://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/MutableIssue.html
I am just having trouble making the leap to contructing the ProjectComponent with a component id and inserting it into the Collection.
Upvotes: 2
Views: 2533
Reputation: 546
If your only problem is to get the ProjectComponent object from its id than in your groovy script you can simply get it:
ProjectComponentManager pcm = ComponentAccessor.getProjectComponentManager();
ProjectComponent pc = pcm.find(long_id);
List<ProjectComponent> list = new ArrayList<ProjectComponent>();
list.add(pc);
Or if you have other identifier or conditions on selected components, you should check http://docs.atlassian.com/jira/5.1/com/atlassian/jira/bc/project/component/ProjectComponentManager.html for more information.
Upvotes: 0