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

How to make a custom field default based on component chosen

Brock April 23, 2014

I am trying to find a way to create a custom field that will default based on the component the user chooses in the Create Issue screen. We use components as our system/applications. We want to be able to choose a system/application and have the custom field default with the correct person that is over that system/application.

Any ideas?

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
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.
April 23, 2014

Hello Brock,

please take a look here https://marketplace.atlassian.com/plugins/com.onresolve.jira.plugin.Behaviours

This is a powerful plugin that allows you to implement this feature.

Hope this helps,

Fabio

Brock April 23, 2014

Thanks Fabio. I've downloaded the plugin, but I'm having an issue. I'm not a developer so I don't know how to write scripts. I saw some of the sample ones here https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA%20Behaviours%20Plugin#JIRABehavioursPlugin-Setonefieldbasedonanotherfieldwithinformationprovidedbytheserver

but I couldn't seem to find what I was looking for.

What I want to be able to do is select a component and have my custom field populate with component lead. I created a user picker custom field named, "Component Lead". Now I need help adding a script to the behaviour that will populate the Component Lead field with right user based off the component selelcted.

Can you help with that?

0 votes
Michael Marley October 3, 2015

Hi Daniel,

 

I tried this myself and it didn't work.  I didn't see anything in the logs either.  Did you ever get this working yourself?

0 votes
Daniel Luevano July 15, 2015

OK, here it is step by step:

  1. Click on Cog icon => Add-ons
  2. Find Behaviours on the left menu (if you have a lot of links on the left menu, type ctrl+F and look for 'Behaviours'
  3. Add a Behavior,
  4. image2015-7-15 10:11:38.png
  5. Click on 'Fields'
  6. image2015-7-15 10:12:13.png
  7. Add the fields involved on the behaviour, in this case ('Component/s' and a custom field added to get the value 'Component Owner')
  8. On the 'Component/s' row click on 'Add serverside script'
  9. And on the script field type this (change your variable names if required, for example my field that will contain the component lead is called 'Component Owner':
  10. FormField formComponent = getFieldById(fieldChanged)
    FormField formUserField = getFieldByName("Component Owner")
    String componentLead
    components = formComponent.getValue() as List
    
    // if any components have been set, set the user field to the component lead of the first component
    // otherwise unset it
    if (components) {
    formUserField.setFormValue(components.first().lead)
    }
    else {
    formUserField.setFormValue("")
    }
  11. Click on Update and try. 
    If you have any errors please let me know when all details you can.
TAGS
AUG Leaders

Atlassian Community Events