Forums

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

How assign component leads to User field(Multi-User Picker) base on the Components field

Yogi Patel April 5, 2018

I am new script Runner and I looking for a solution or  a script to do following:

1. Components Field has multiple values such (JIRA, APP)

2. Get the Component leads for each of the Components in Component field

3. Copy the Component leads to User field(Multi-User Picker)

 

Thanks

1 answer

0 votes
Ivan Tovbin
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.
April 5, 2018

Hi Yogi, 

I might be able to help you here, but first please advise what is the version of your Jira?

Cheers.

Yogi Patel April 7, 2018

Jira 7.8

Yogi Patel April 7, 2018

Thanks for support. Please adivise

Ivan Tovbin
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.
April 8, 2018

Ok, assuming we are talking about a scripted field, here's what you do:

return issue.getComponents().collect{it.getComponentLead()}

Make sure you choose "User Picker (multiple users)" template when creating your scripted field. Also set the field's searcher to "User Picker & Group Searcher".

If this you need a post function instead, then use this code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("name of your user field")

issue.setCustomFieldValue(cf, issue.getComponents().collect{it.getComponentLead()}
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

 

Like Prathyush Thummepalli likes this
Yogi Patel April 19, 2018

Thanks, Ivan. It worked.

Ivan Tovbin
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.
April 20, 2018

@Yogi Patel Great news! Glad I could help. Please mark this solution as "Accepted" if it resolved your issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events