Forums

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

Set assignee from component lead using script listener

Alvin
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 Champions.
September 13, 2018

Hello Community, I need help on scriptrunner, I need to set assignee based on the component's lead. Below is the code that I'm using

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption


// a map with select list option to Component
def componentsMap = [
"BOSS" : "Component1",
"Mashery" : "Component2",
]

def issue = event.issue as MutableIssue

def selectList = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Affected Service")
def selectListValue = issue.getCustomFieldValue(selectList) as LazyLoadedOption

// there is no value for the select list - therefore do nothing
if (! selectListValue) {
return
}

def componentManager = ComponentAccessor.projectComponentManager
def componentName = componentsMap.get(selectListValue.value)
def component = componentManager.findByComponentName(issue.projectObject.id, componentName)
def userManager = ComponentAccessor.userManager
def components = issue.componentObjects.toList()

if (component) {
componentManager.updateIssueProjectComponents(issue, [component])
}
issue.setAssignee(ComponentAccessor.userManager.getUserByKey(component.lead))

 

In this code, I have Affected Service as a single select list, if BOSS has been selected, the Component Field will update and set to Component1, but the assignee remains unassigned even if I have default assignee on my component. I know that there's something wrong with my code because I'm a beginner. I need to change assignee everytime component field is changed, that's why I used script listener. Thanks

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Antoine Berry
Community Champion
December 5, 2017

Hi,

Any update on this ?

Thanks,

Antoine

Katy Kelly
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 Champions.
December 5, 2017

Hi Antoine,

As noted in the support ticket you submitted we already have a feature request ticket for this which you were added to. Please follow it here: https://productsupport.adaptavist.com/browse/SRJIRA-2563

Regards,

Katy

Antoine Berry
Community Champion
December 5, 2017

Hi Katy,

This is not the same issue. This is about Insight only (not behaviours). We would like to have filters management on Insight the same way as on Jira =>

  • Save favourite filters (IQL)
  • Subscribe to a filter

Best regards,

Antoine

Katy Kelly
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 Champions.
December 5, 2017

Hi Antoine, 

Sorry about that. Someone from Insight should hopefully respond then. Insight is from Riada, not Adaptavist. 

Regards,

Katy

Antoine Berry
Community Champion
December 5, 2017

You are right sorry. I re-created the ticket in the Marketplace section.

1 vote
Mathias Edblom
Contributor
January 18, 2018

Antoine,

This feature request is in our road map and will most likely be implemented this year.

Cheers //Mathias

Sanja Vukovic
February 15, 2018

Please attach the link for it so that I can vote for it and follow it.

Antoine Berry
Community Champion
February 15, 2018
TAGS
AUG Leaders

Atlassian Community Events