Hi,
I am looking the way to get values selected in components on Transition/Edit screen and update it using script listener. Which Listener needs to select and how to write script. I needs this update as soon as someone select component on Edit screen or transition screen to show values in another db field to display user list based on above selected component.
Thanks in advance.
Hi!
You can try this code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)
Issue updatedIssue = event.getIssue()
Collection <ProjectComponent> componentList = new ArrayList<ProjectComponent>()
componentList = updatedIssue.getComponents()
Collection<Issue> subTasks = updatedIssue.getSubTaskObjects()
subTasks.each {
if (it instanceof MutableIssue) {
((MutableIssue) it).setComponent(componentList)
issueManager.updateIssue(event.getUser(), it, EventDispatchOption.ISSUE_UPDATED, false)
}
}
https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-using-a-listener can give you the skeleton of a listener which is close to what you want to do.
You can use issue.getComponents() to get the list of components from the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.