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

Tomas Arguinzones taart1 August 4, 2014

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

2 votes
Answer accepted
Vidic Florjan
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.
August 4, 2014

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

Tomas Arguinzones taart1 August 4, 2014

Hi Vidic,

Thank you for your answer.

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

Thanks

Vidic Florjan
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.
August 4, 2014

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)

Tomas Arguinzones taart1 August 4, 2014

Hi Florjan,

Works flawlessly!

Thanks a lot

Suggest an answer

Log in or Sign up to answer