It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
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])
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.