Skip to main content

How to export a list of Jira custom fields to csv (Jira Data Center)

 Hello All !

As a Jira administrator it is very important to keep an eye on the number of custom fields you have in your instance because the number of custom fields directly impact your instance performance. Atlassian also has confirmed this in their documentation

One of the important strategies to keep your custom field number low is to reuse them as much as possible across projects. When you get a request from a user to create a custom project, you can provide a list of custom fields upfront, and ask the user to choose existing fields instead of creating new ones. Out of the box, Jira doesn't provide an easy way to export the custom field list to a csv file to share with non Jira admin users.

In this blog I will share how I exported all Jira custom fields into a csv file using Jira REST API and Python.

This solution was tested on Jira Data Center version 8.x, Python3 and Windows 11. Let's see how we can get the custom field list in 3 easy steps.

Note: I assume that you have Python setup in your environment where you will run the script in Step 3 and you know how to run a python script. Also, you need to have Jira administrator access to your instance.

Step 1: Login to your Jira instance as a Jira Administrator and go to this url https://your.instance.domain/rest/api/2/customfields?startAt=1&maxResults=2000. This url will return a JSON response to the screen with custom fields in your instance. Change the maxResults parameter based on the number of fields in your instance.

Step 2: Copy the entire JSON response returned on your screen and save this to a text file named "fields.txt".

Step 3 : Copy the below code and save this into a ".py" file (ex: export_fields.py). Then place the file created in Step 2 (fields.txt) in the same folder as the ".py" file. Finally run the python script.

import csv, json
from datetime import date

input_file = open ('fields.txt')
json_object = json.load(input_file)
json_array = json_object['values']
field_list = []

for item in json_array:
    field_details = {"Id":None, "Name":None, "Type":None}
    field_details['Id'] = item['id']
    field_details['Name'] = item['name']
    field_details['Type'] = item['type']
    field_list.append(field_details)


print(len(field_list))

current_date = date.today().strftime("%Y-%m-%d")
extention = '.csv'
csv_file_name = "Jira Custom Field List  " + current_date

csv_columns = ['Id','Name','Type']  
csv_file = csv_file_name + extention
try:
    with open(csv_file, 'w', newline ='') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
        writer.writeheader()
        for data in field_list:
            writer.writerow(data)
except IOError:
    print("I/O error")                                                                                                                                     

Step 3 will generate a CSV file in the same folder with all custom fields in your system including field name, field type and field id. You can then share this with your internal users who will be requesting new fields.

Thanks for taking your time to read this post. Hope this will help you !

Comments

Popular posts from this blog

How to setup Jira SLAs for global teams across multiple time zones (Jira Cloud & Jira Data Center)

Hello All! Being a global company creates the need to have IT teams across different parts of the world in different time zones. When you have team members working in different time zones you also need the ability track SLAs for the work they do. In this blog I will go over a solution to track Jira request SLAs for global teams across multiple time zones. Scenario: IT department have three teams in three different time zones (Barcelona, New York,  Los Angeles).  Employee requests are processed by the IT team assigned to the location of the employee. All three IT teams work from 9:00 AM to 5:00 PM (Monday - Friday) in their respective time zones.  Every request submitted to IT needs to be resolved within 40 business hours.  Requests can be transferred to another team and the SLA clock should be updated to use the respective time zone of the teams location.  Office Location Timezone Hours (M-F) Time to resolution Barcelona CET 9:00 AM - 5:00 PM 40h New York EST 9:00 AM - 5:00 PM 40h Los

How to setup bump bump solve in Jira (Jira Cloud & Jira Data Center)

Hello All ! One of the pain points of working on support tickets is following up on tickets when more information is needed from the reporter. This can take quite a bit of time from support agents when they have to go into each "Pending" ticket daily and add a comment for the reporter reminding that more information is needed to process the ticket. If there is a way to setup auto follow ups on tickets and resolve them if there is no response from the reporter ( bump bump solve ), this will reduce a considerable amount of work from support agents daily. Out of the box Jira doesn't provide an option to set this up. After doing some thinking, I was able to come up with a solution using SLAs and Jira Project automations to implement "bump bump solve" for a Jira Service Management project. In this blog I will go over the solution and how I set this up in Jira. Scenario: IT team members put tickets in to "Pending" status when they are waiting for more inform

How to export Jira project lead email addresses to csv (Jira Data Center)

Hello All! Upgrading a large Jira Data Center instance is no easy task. One of the main steps of this process is communicating to project leads about this. When there are hundreds of Jira projects in your instance, it can be tedious to manually find the email address of each project lead. In this blog I will share how I exported all Jira project lead email addresses into a csv file using Jira REST API and Python. This solution was tested on Jira Data Center version 8.x ,  Python3 and  Windows 11 . Let's see how we can get this email list in 3 easy steps. Note: I assume that you have Python setup in your environment where you will run the script in Step 3 and you know how to run a python script. Also, that you have access to all Jira projects in the instance because REST API will only return data from projects where you have access.  Step 1: Login to your Jira instance. Go to the url https://your.instance.domain/rest/api/2/project?expand=lead. This url will return all projects in