Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can I programmatically delete custom fields in jira?

dmitri October 13, 2016

related to:

https://answers.atlassian.com/questions/51896

https://answers.atlassian.com/questions/9868061

https://answers.atlassian.com/questions/13416427

i want to delete hundreds of custom fields. is it possible to do this without clicking through the UI for each custom field?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 14, 2016

Hi Dmitri,

If you write your own plugin or use Script runner, below code can simply delete custom fields. 

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
Collection<CustomField> customFields = customFieldManager.getCustomFieldObjects();
for (CustomField field: customFields) {
	if (checkFieldToBeDeleted(field)) {
		customFieldManager.removeCustomField(field);
	}
}

As far as I know there is no REST support yet to do that, but there is a quite old open issue regarding that.

Hope it helps,

Tuncay

dmitri October 22, 2016

Perfect. Thanks.

0 votes
Alexey Dorofeyev
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 15, 2017

Before deleting custom fields you can review their values using Custom Fields Usage plugin

https://marketplace.atlassian.com/plugins/systems.npe.jira.cfu/server/overview

0 votes
Richard Cross January 19, 2017

Can anyone from Adaptavist elaborate on how to delete a bunch of custom fields quickly with ScriptRunner for JIRA?  For example, I'd like to delete all the fields starting "abc".

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 19, 2017

Hi Rıchard,

Actually you can do that with the script above (I provided).

within checkFieldToBeDleted function all you need to do is return true if custom field's name starts with "abc". Similar as below

def checkFieldToBeDeleted(field) {
	return field.name.startsWith("abc")
}
Like rusguliev likes this
0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
October 14, 2016

You can use the removeCustomField action from JIRA Command Line Interface (CLI). You may want to wrap that with one of the run actions like runFromCsv or runFromSql.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events