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

Hi,

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

Thanks

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
   {
       fgroup.setFormValue("jira-administrators")
   } else if (vtype =="3") 
   // 3 - issue type id for  Task
   {
       fgroup.setFormValue("jira-developers")
   } else if (vtype =="4") 
   // 4 - issue type id for Improvement
   {  
       fgroup.setFormValue("jira-users")
}

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

Regards,
Florjan

Hi Vidic,

Thank you for your answer.

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

Thanks

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.

Regards,
Florjan

(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: https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA%20Behaviours%20Plugin#JIRABehavioursPlugin-Installation)

Hi Florjan,

Works flawlessly!

Thanks a lot

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,329 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot