Hello,
I am running a Datacenter instance (8.20.14) and I need to perform an audit on all unused custom fields (and we have a large amount).
I have used the Jira tool "Custom Fields Optimizer" to a list of all custom fields within a project but unfortunately, this tool does not allow an export of all custom fields to a CSV file so I can manipulate it.
Is there a way via either Scriptrunner or the API I can get this list on Datacenter?
Hi @NSEU DevOps Check this doc for managing custom fields :- https://confluence.atlassian.com/enterprise/managing-custom-fields-in-jira-effectively-945523781.html
OR you can run the following script in Script Console to get a list of empty custom fields :-
import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default")
def sqlStmt = """
select count(*), customfield.id, customfield.cfname, customfield.description
from customfield left join customfieldvalue on customfield.id = customfieldvalue.customfield
where customfieldvalue.stringvalue is null
and customfieldvalue.numbervalue is null
and customfieldvalue.textvalue is null
and customfieldvalue.datevalue is null
group by customfield.id, customfield.cfname, customfield.description;;
"""
Connection conn = ConnectionFactory.getConnection(helperName)
Sql sql = new Sql(conn)
String result = """
<table>
<tr>
<th>Customfield Name</th>
<th>Customfield Id</th>
</tr>
"""
sql.eachRow(sqlStmt){ it ->
result += """
<tr>
<td>${it.getAt("cfname")}</td>
<td>${it.getAt("id")}</td>
</tr>
"""
}
return result+"</table>"
sql.close()
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.
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️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.