Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Behaviours Plugin populate custom field based off component

Brock April 28, 2014
I want to be able to select a component and have my custom field populate with the component lead. I created a user picker custom field named, "Component Lead". I've added field behaviours on the component field and the component lead field. Now I need help adding a script to the behaviour that will populate the Component Lead field with right JIRA user based off the component selelcted.

I'm not a developer so I don't know how to write scripts. I saw some of the sample ones in the link below, but I couldn't seem to find anything that could help me.

https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA%20Behaviours%20Plugin#JIRABehavioursPlugin-Setonefieldbasedonanotherfieldwithinformationprovidedbytheserver

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Brock May 18, 2014

I haven't gotten a chance to try the script, but we decided to just stick with manually entering the component leads in. In the event that the component lead changes, we don't want to have to worry about the maitenance of the script.

1 vote
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 2, 2014

Hi Brock,

here the script that you need

import com.atlassian.jira.bc.project.component.ProjectComponent
FormField componentFF = getFieldById(fieldChanged)
FormField userPickerFF = getFieldByName("User Picker Field")
List<ProjectComponent> components = componentFF.getValue() as List
if(components){
    userPickerFF.setFormValue(components.first().lead)
} else {
    userPickerFF.setFormValue("")
}

Add this code into your behaviour associated to field "Components".Moreover, update "User Picker Field" with the correct name of your custom field. Since COmponent/s allows you to select multiple values, my script will update your custom field with the lead of the first selected component.

Hope this helps,

Fabio

Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 4, 2014

any update on that?

Eunice Mora October 7, 2014

Thanks Fabio for providing the script. I used your script on my existing behavior and it worked great!

Eunice Mora October 7, 2014

Note: JIRA V6.3.3

0 votes
Eva
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.
May 2, 2014

I am not sure why you are using Behaviour plugin? This seems like a simple script using a script runner (also by Jamie who created Behaviour plugin). If you download and install Script runner (which also means you need to install groovy language), then you just search in Answers for one of many examples in here for copying custom field using this plugin, that should do the trick

TAGS
AUG Leaders

Atlassian Community Events