Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,335
Community Members
 
Community Events
165
Community Groups

Bulk delete Custom fields in Jira cloud

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 ?

3 answers

1 accepted

1 vote
Answer accepted

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-

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.)

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

2 votes
Darryl Lee Community Leader Jan 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

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
Pramodh M Community Leader Jan 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

Need this now...

Suggest an answer

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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you