A new custom field that uses the values from an existing custom field

Dan Hellings February 12, 2018

We require a way to use multiple custom fields that look at a list of values from another custom field. An example could be tagging a defect to a Test Environment. We would have a list of test environments. Then we need to create three custom fields to capture the following:

1) The environment the defect was found in

2) The environment the defect's fix was tested in

3) The environment UAT tested the defects fix

So we need three custom fields, but they need to look at one list of custom field values. Otherwise we have to add three fields with the same values, and whenever the values change we would have to update this in three areas.

Is there a way where a standard custom field could use the values from another custom field? Similar to the way the Version fields work with the Releases/Versions.

 

1 answer

0 votes
Ivan Tovbin
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.
February 12, 2018

Hi Dan, 

The solution here is to create a scripted custom field which would be populated automatically with the value or values from other fields. I might be able to assist further if you could provide a more detailed description of your use case. Specifically the type of your source custom field (my money's on a multi-line text field type).

Dan Hellings February 12, 2018

Thanks @Ivan Tovbin,

The field we are using would be a Multi Select field called "Environment found in", that has values of various environments within it, e.g. "Environment A", "Environment B", "Environment C" and "Environment D". We would then create two more fields:

1) Environment fix tested in

2) Environment fix UAT tested in

We would like the two fields above to simply display the same values as the "Environment found in". So everytime we add a new value in this field it will be available in all three custom fields.

So we would create two new scripted fields. What would we need to add to get these fields to display the values?

Thanks again,

Dan

Ivan Tovbin
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.
February 12, 2018

Assuming the id of your 'Environment found in' field is '11111' the code should look something like this:

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11111.toLong())
String cfValueString = issue.getCustomFieldValue(cf).toString()
return cfValueString.substring(1, cfValueString.length()-1)

Suggest an answer

Log in or Sign up to answer