Can you bulk disable custom field values from within Jira?

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2020

I have a scenario where several hundred field values need to be disabled for a multi-select list custom field in Jira. Is there any way to bulk disable custom field values within the Jira interface, perhaps with Scriptrunner?

Or, is disabling values one by one the only way to handle this from within Jira?

Thanks!

Andrew

 

 

3 answers

1 vote
Raynard Rhodes July 21, 2020

I was able to use this to disable options from a customfield. I can't remember what kind of customfield it was but it may lead you to the right place. This script was used in the Script Console

 

import com.atlassian.jira.component.ComponentAccessor 
//Any ticket number can be used that has the targeted custom field
def issue = ComponentAccessor.getIssueManager().getIssueObject("JA-iiii")
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Custom-field Name")
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(customField.getRelevantConfig(issue))
options.each 
{    
if (options)
{
        
optionsManager.disableOption(it)    
}
}

 

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 21, 2020

Awesome! Thanks for sharing @Raynard Rhodes - I appreciate it!

-- Andrew

Mohan Sundar January 21, 2021

This script worked like charm!! Thankyou!!!

Srikanth Ganipisetty March 3, 2022

@Raynard Rhodes 

Oops!!

Unfortunately, your script was updating all options in the given custom field 'we used custom field by name' rather than updating custom field + single jira ticket. 

it updated 3K+ records in a go quickly.. the script needs to be developed before we execute everything. 

 

@Mohan Sundar  Have you made any improvements to the script before we execute,, because it messed up our data? 

 

Thanks,

Srikanth Ganipisetty

Mohan Sundar March 4, 2022

@Srikanth Ganipisetty The script is to disable all the custom field values if they are enabled. 

I had changed the issue id and the Custom field name and then executed it.

Thumb rule: Try to have a test custom field with few values and test project to test any such scripts.

Like Srikanth Ganipisetty likes this
Raynard Rhodes March 4, 2022

@Srikanth Ganipisetty 

I think this is a valuable lesson to test scripts in test environments before just executing random internet code.

Like # people like this
Srikanth Ganipisetty March 5, 2022

I agree @Raynard Rhodes I ran on test environments, but we have 1000_ records to turn back into enabled, where my intial task is to disable only 50+ records. It's a valuable lesson. 

@Mohan Sundar I should have do that trying it on a test custom field. 

Thanks,

Srikanth Ganipisetty

0 votes
chithra madhav December 9, 2020

Hi ,

 

I have a custom field[Single Select list] with 5 options in it. I have disabled one option with Custom Field Configuration in Jira. When i import issues with CSV with disabled Custom Field Option it is creating new issue..how to block it from creating issues with disabled options.

Suggest me some answers,

 

Thanks in Advance

0 votes
Ravi Sagar _Sparxsys_
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.
April 15, 2020

Hi @Andrew Zimmerman _Appfire_ 

Can you explain your use case a bit in detail?

Using ScriptRunner you can create a behaviour to disable those values or split the custom field contexts and few more things as well with a custom script.

Ravi

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 15, 2020

Hey @Ravi Sagar _Sparxsys_

Sure thing. Essentially the custom field is a multi-select list of our customers over the years. We formatted it this way so that users would not make errors in spelling or use inappropriate shorthand/abbreviations when referring to customers. With a select list, we can ensure the customer names on tickets are always spelled the same way, we can use the values in logic, and VLOOKUPs with data manipulation from reports from other systems, etc. 

Because this field is available in many of our Jira projects and because it's considered the standard authoritative source for customer names in Jira, it only has one, global field context.

Over the years it's become extremely bloated as lapsed customers or accounts that are no longer active are still selectable. We still need their values in Jira to query and report on, but they will not be newly selected, so I'd like to disable them to clean up the current selectable list for end users.

I have a CSV of exactly the custom field value options that need to be disabled, exactly as they are spelled in Jira. Since it's several hundred values, I'd love to be able to import that list and have Jira disable any value that matches for my specified custom field, rather than doing so one by one in the Custom Field>Edit Options page.

But, that's where I'm stuck. I'm not sure such a thing is possible within the Jira UI.

Like Srikanth Ganipisetty likes this
Jaswanth P July 20, 2020

Hi Andrew, I have a similar scenario. Were you able to figure it out?

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2020

Hey @Jaswanth P !

I wasn't able to find a solution that utilized my CSV list. But, @Merita Bushi, another admin on our team, discovered that you don't have to wait for the enable/disable/edit request to resolve in your main "edit options for custom field" screen if you open in a new tab.

So, I'm able to get through these pretty quickly by simply command+clicking (I'm on a Mac) on the "Disable" option as I scroll down the custom field value options.

I can't completely vouch for safety of this method regarding system performance, although I haven't had problems. You may want to monitor your CPU or perform this task outside of prime business hours just in case. I was just tired of waiting for the value option list to refresh after every single edit or disable action. Since the total list is so long, it would take 15s to refresh after making an option edit, disable, or enable and when you have to edit or disable 100 options, that really adds up.

Hopefully this helps a little,

Andrew

Like Srikanth Ganipisetty likes this
Jaswanth P July 20, 2020

Thanks Andrew. Not a bad approach if we can spend few minutes. I will try it. I have about 500 values to disable and was planning to write a SQL script to set the 'disabled' flag to 'Y' in customfieldoption table. 

It would be great if scriptrunner or Atlassian themselves provide some solution to this.

Andrew Zimmerman _Appfire_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2020

Right, yeah with 500 it'll take a bit done manually. Sounds like you're going to work through this method and have already seen this page, but linking it here just in case!

I scanned through some developer docs but couldn't figure out how to do what I was searching for. I came upon a few potentially related tickets, but one is already resolved as won't do.

https://jira.atlassian.com/browse/JRASERVER-41661

https://jira.atlassian.com/browse/JRASERVER-60274

There could very well be a useful fragment in the Scriptrunner Library. I just couldn't find it and decided to start going through the list manually. 

If you go with the SQL script route, I'd be interested in hearing how it turns out and if the process was relatively straightforward or not.

Take care,

Andrew

Srikanth Ganipisetty March 3, 2022

@Andrew Zimmerman _Appfire_ @Jaswanth P 

which method works for you both? we have 100+ in a MLCS field consisting 6000 records, and the page is really slow and it takes so long to update 1 field and to wait for the refresh etc. 

Jaswanth, have it worked through SQL method? 

Thanks,

Srikanth Ganipisetty

Suggest an answer

Log in or Sign up to answer