Bulk delete Custom fields in Jira cloud

Preethi Srikakula January 29, 2021

Post migration we have ended up with unwanted custom fields which were part of default field configuration .

Is there a way I can bulk delete Custom fields in Jira cloud ?

4 answers

1 accepted

2 votes
Answer accepted
Preethi Srikakula January 30, 2021

How about I use scriptrunner script to delete unwanted custom fields . I found this info about Customfieldmanagerinterface and there is function "removeCustomField(CustomField customField) " Can i use this in loop and delete?

 

https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/CustomFieldManager.html#removeCustomField-com.atlassian.jira.issue.fields.CustomField-

Darryl Lee
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 30, 2021

Hi, I love the idea of using Scriptrunner (especially if you have it), but I don't think that'll work.

The API you reference is for server, but even more importantly, it's an internal API. Scriptrunner on Cloud can only talk to REST APIs.

And from this bug, it appears that there is no REST API for deleting a custom field: https://jira.atlassian.com/browse/JRACLOUD-28539

However, I just tested the CLI command I posted above, and it worked, so I have to assume that @Appfire Support is using the undocumented APIs/endpoints that @Peter Majeed discovered and documented in that ticket:

Below are some workarounds I found useful as of 2020-11-17.

There's an undocumented REST API for trashing fields.

POST https://your-company-name.atlassian.net/rest/api/2/field/customfield_xxxxx/trash

Once you trash a field, it will be deleted after 60 days. To permanently delete the field, not sure if there's a REST API, but Jira currently uses an undocumented jspa page to do this. You will need a token from the browser to execute this request.

POST https://your-company-name.atlassian.net/secure/admin/DeleteCustomField.jspa
FormData: id=xxxxx&Delete=Delete&atl_token=browser_token

Bottom line: I don't think you'll be able to do it with Scriptrunner, but... it wouldn't cost you anything to try it with CLI.

For reference, here's a transcript of my testing session:

$ acli --action removeCustomField --field "Multi"
Custom field 'Multi' removed. Field had id customfield_10078.

I'll note that the field was deleted. It does not show up in the new "Trashed" tab for Custom Fields. (Hey @Appfire Support that might be a nice feature to offer.)

Preethi Srikakula January 31, 2021

Thanks @Darryl Lee  for detailed explanation and help . Will try out the CLI as suggested .

Perry Tancredi February 14, 2024
3 votes
Darryl Lee
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 29, 2021

There's no way to bulk delete custom fields within Jira itself.

But you could put together a shell script/batch file that uses Atlassian CLI to run several removeCustomerField commands:

https://bobswift.atlassian.net/wiki/spaces/JCLI/pages/1059398143/removeCustomField

Example (after you've installed and configured it. By the way, I highly recommend setting up a configuration property file):

acli --action removeCustomField --field "Field You Don't Need" --continue
acli --action removeCustomField --field "Another Field You Don't Need" --continue
acli --action removeCustomField --field "Unneeded field" --continue
Bob Swift {Appfire} February 1, 2021

fyi... the --continue on the removeCustomField action is just a way to ignore a not found error so you can run your script multiple times if needed if you add more fields later when testing.

Also, a slight improvement would be a single command:

acli -a runFromList --list "Field You Don't Need, Another Field You Don't Need, Unneeded field" --common "-a removeCustomField --field \"@entry@\" --continue"

Note: use "" instead of \" to do escaping on windows.  

Like # people like this
0 votes
Rodolfo Romero - Adaptavist April 12, 2024

There are now 2 REST endpoints that allows you to get the list of custom fields in the trash, and delete them.

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/#api-rest-api-3-field-search-trashed-get

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/#api-rest-api-3-field-id-delete

A python script can be quickly implemented to 1) get the list in the trash and; 2) iterate over the list to delete each custom field.

0 votes
Pramodh M
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 29, 2021

Hi @Preethi Srikakula 

This feature is not available yet.

The request is open here, https://jira.atlassian.com/browse/JRACLOUD-37773

Thanks,
Pramodh

Preethi Srikakula January 31, 2021

Thanks Pramodh

Rob Horan
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.
June 9, 2022

Need this now...

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events