Hello,
I'm trying to create sub-tasks depending on the selection of some custom fields. For each selected custom field, there should be a corresponding sub-task. This is working great so far with the newest ScriptRunner-Addon and specified validators.
Here comes the issue: Additionaly I would like to set corresponding components for the created sub-tasks within the "create a sub-task" function.
I'm using JIRA 7.4.4 with ScriptRunner 5.1.6.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.project.Project
import com.atlassian.jira.bc.project.component.ProjectComponent
//set components - NOT WORKING
MutableIssue issue = issue
Project project = issue.getProjectObject()
ComponentManager componentManager = ComponentManager.getInstance();
def component = componentManager.getProjectComponentManager().findByComponentName(project.getId(),'ComponentName')
issue.setComponentObjects([component])
I'm getting this error:
Hello,
You use deprecate ComponentManager. Try like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.project.Project
import com.atlassian.jira.bc.project.component.ProjectComponent
//set components - NOT WORKING
MutableIssue issue = issue
Project project = issue.getProjectObject()
def component = ComponentAccessor.getProjectComponentManager().findByComponentName(project.getId(),'ComponentName')
issue.setComponent([component])
Awesome! Thank you so much for such a fast solution for my problem! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.