How to query (SQL) all custom fields not being used in any screen

Flavio Beck August 20, 2015

I have several custom fields (around 250) and some of them are not being used anymore (but may have some value or not).

JIRA customfield interface is not very good to find inactive custom fields (like it work to find inactive workflows).

 

I would like to query database to list all customfields (id or name) that are not applied in any screens.

After that I will check if the field has some value (JQL) and if it is OK to be deleted (maybe the value was migrated to a new field).

 

 

 

3 answers

1 vote
GabrielleJ
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.
August 20, 2015

I'm not sure for the SQL, but in the JQL, I have used the query below to cleanup my 500+ custom fields before

"Custom Field" is not NULL

The results of this query will be all the issues that have this custom field. If it returned 0 results, then you may 86 that custom field without any worries.

Dalectric
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 27, 2016

You have to be careful with that, even though the fields maybe empty if you have a workflow that sets the value, then you can break the workflow when it tries to set the customfield you just deleted. I found this out the hard way sad

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.
September 20, 2018
0 votes
Krzysztof Skotnicki February 27, 2018

Have you found a solution? (sql?)

Krzysztof Skotnicki February 27, 2018
SELECT CF.cfname, count(CV.ISSUE) FROM customfield CF join customfieldvalue CV on CF.ID = CV.CUSTOMFIELD
group by CF.cfname
Like Omid H_ likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 27, 2018

That tells you fields used on issues, but not whether a field is in use on a screen (or in other places like workflows)

Dalectric
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 27, 2018

Here's some more SQL I run to check for use of customfields

Dashboard gadgets

SELECT *
FROM
    gadgetuserpreference
INNER JOIN portletconfiguration ON portletconfiguration.id = gadgetuserpreference.portletconfiguration
INNER JOIN portalpage ON portalpage.id = portletconfiguration.portalpage
WHERE
    userprefvalue LIKE '%12340'

Filters

select * from searchrequest s where s.reqcontent like '%MyCFName%' or s.reqcontent like '%cf[12940]%'

Screens

SELECT cf.id, fsli.fieldidentifier, cf.cfname, fs.name, fst.name FROM fieldscreenlayoutitem fsli
INNER JOIN fieldscreentab fst
ON fsli.fieldscreentab = fst.id
INNER JOIN fieldscreen fs
ON fst.fieldscreen = fs.id
INNER JOIN customfield cf
ON fsli.fieldidentifier = 'customfield_' || cf.id::text
WHERE fsli.fieldidentifier LIKE '%customfield_10009%'

Workflows

select * from jiraworkflows wf where wf.descriptor like '%customfield_12940%';
Like # people like this

Suggest an answer

Log in or Sign up to answer