Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira script listner how do i get component value on transition/edit screen

Omprakash Thamsetty
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2019

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.

2 answers

0 votes
Charles Huggins October 9, 2020

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)
}
}

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 28, 2019

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events