Hi,
I have a custom field (Single_Select) in my jira instance. The field has some option values in it, most the values has been disabled. As we are in process of cleaning up our instance, so we want to delete the disabled values from custom field option. Let me know if there is any way i can delete those values from "Script Runner" and how? Because there are approx. >100 option values.
Hello @Manu Mishra
Try this, replace issue key with actual issue key and test it in staging environment first
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1") // get issue where field exist
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Your CustomField Name")
def optionsManager = ComponentAccessor.getOptionsManager()
def options = optionsManager.getOptions(customField.getRelevantConfig(issue))
options.each {
if (it.getDisabled()){
optionsManager.deleteOptionAndChildren(it)
}
}
I believe the script will delete the "custom field" from the issue where the the field exist. However my question is different, i want to delete the options value from the custom field, i have enclosed the screen shot for your reference.
Basically when we go to Admin>Issues>Custom Fields>Configure>Edit Options . So there are many custom field options, so what i want is to delete those option values which are disabled. In the screen shot there are 5 CF values, out of which we need to delete only (#2, #4)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And script above will delete this options from configuration.
It looks strange, because optionsManager need some context. It is architecture feature.
I ve tested it on my environment and it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mark Markov
So what's the issue key i have to pass? there are so many issues where this value exist and we only want to delete (cd & gh)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any issue key, where field exists on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So according to you, when we pass any issue key in variable, so option under that field will be deleted from field config? What i concerned about, this should not delete the custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i ran this script from script console (script runner), however it not doing anything. Means, neither it deleted the option from issues nor under custom field config. Rather printing the output like above:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This output is normal.
Are you sure that it not deleted from config?
I ve checked it again and it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can use the Power Scripts add-on to delete such options. Here is the link to the Power Scripts add-on:
For example, to delete the "Option" from the global context of custom field "Select List" would be like this:
admDeleteCustomFieldOption("Option", "Select List");
You can find more info on admDeleteCustomFieldOption here:
https://confluence.cprime.io/display/SIL/admDeleteCustomFieldOption
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.