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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,559,514
Community Members
 
Community Events
184
Community Groups

list of unused custom fields via scriptrunner

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?

1 answer

1 accepted

0 votes
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 24, 2023

Hi @Alex Hutchinson  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()
Like Vikrant Yadav likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 25, 2023

You're Welcome :)

Suggest an answer

Log in or Sign up to answer