How to set the value of a custom field based on Issue Type


I need to set the value of a group picker custom field based on the value in Issue Type. How to accomplish that?


1 answer

1 accepted

Hi Tomas,

You can try this code:

FormField ftype = getFieldById(fieldChanged) 
FormField fgroup = getFieldByName("Group")
String vtype = (String) ftype.getFormValue()

if (vtype =="2") 
   // 2 - issue type id for  New feature
   } else if (vtype =="3") 
   // 3 - issue type id for  Task
   } else if (vtype =="4") 
   // 4 - issue type id for Improvement

Please change your issue type ids and rename name "Group" with your Group picker custom field name.


Hi Vidic,

Thank you for your answer.

Where do I enter this code? I am on JIRA 6.2.2


Hi Tomas,

  1. Go the Administration sceen, select Add-ons tab and click the Behaviours link on the left side of the screen.
  2. You will see Add Behaviour label somewhere in the center of the screen. Add a name of your behaviour in Name field (e.g. My behaviour) and click on Add button to add your behaviour.
  3. Now you will see the name of your behavior on the screen. On the right side is link Fields. Click on it.
  4. In screen with information of your behaviour select Issue Type in Add field field. Confirm entered information by clicking on Add button.
  5. Information about Issue Type field will appear on you screen. Click on Add serverside script link and insert code.
  6. Confirm your code by clicking on Update button at the end of code.


(I have jira v. 6.1.3. I hope that procedure will be similar in your case.
You can find additional information in Behaviours documentation:

Hi Florjan,

Works flawlessly!

Thanks a lot

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira

Mission-critical battery manufacturer fulfills FAA software requirements with Commit Policy Plugin

EaglePicher Technologies is a leading manufacturer of battery systems for diverse industries like defense, aviation, space or medical. As they operate in highly regulated industries, keeping a clear ...

127 views 0 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you