Copy custom field options from one field configuration to another

Kate Secor September 21, 2023

I have a use case as follows:

Our company-wide releases are tracked in a field called "Release Target."

We also have a field called "Found During Release" that tracks what release people were testing when they found a defect. 

"Release Target" and "Found During Release" should have the same options in their drop-downs. 

(Yes, I am aware that this duplicates the Fix Version(s)/Affects Version(s) functionality, but that's on a project-by-project basis and we needed to be able to track it system wide.)

Is there any way to automatically copy the options from one field configuration to the other? I can find lots of answers on how to copy the *values* in existing issues, but nothing about how to update the configuration options.

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2023

Hi @Kate Secor

In your description, you asked:-

Is there any way to automatically copy the options from one field configuration to the other? I can find lots of answers on how to copy the *values* in existing issues, but nothing about how to update the configuration options.

Can you please clarify if you want the options that have been selected in one Custom Version Picker to be passed on to another Custom Version Picker, or do you want the Versions options available in the 1st version picker to be also available in the 2nd version picker?

If it's the former, it is doable via ScriptRunner Behaviour. 

If it's the latter, there is no need to do anything because all available versions in a Jira Project will be accessible by any Version Picker.

For the former, below is a sample working Server-Side Behaviour code for your reference:-

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours behaviours
def sampleVersion1 = getFieldById(fieldChanged)
def sampleVersion1Value = sampleVersion1.value as List
def sampleVersion2 = getFieldByName('Sample Version 2')

if (sampleVersion1Value) {
def selectedOptions = sampleVersion1Value.collect {
it as String
}
sampleVersion2.setFormValue(selectedOptions)
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the Behaviour configuration:-

behaviour_config_example.png

So, for this case, whenever the selected options are updated in the first Custom Version Picker, in this case, Sample Version 1, the options in Sample Version 2 will automatically be updated accordingly.

I hope this helps to solve your question. :-)

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Kate Secor September 22, 2023

Ram -

Thanks! That code is exactly what I needed.

Kate

Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 22, 2023

Hi @Kate Secor

Great to hear the solution worked. :-)

Please accept the answer provided.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer