This script takes a list of custom field names, and searches each issue in the instance for places where that custom field has been used (i.e., where it has a value other than null).
In this way, we gain insight into the usage of custom fields within a Jira Cloud instance.
The script is interesting for a number of reasons. First, it’s another instance of us having to parse a rawBody response before we can make use of it. Second, it handles the need for pagination, which we’ve also talked about in recent posts.
My intent for this script is for it to serve as a basis for future custom field work in Jira Cloud. Namely, I’d like to be able to easily rename any field with “migrated” in the title.
import groovy.json.JsonSlurper def stillPaginating = true //Loop to paginate def startAt = 0 //Start at a pagination value of 0 def maxResults = 50 //Increment pagination by 50 def issueIDs =  def fieldNames = ["Actual end", "Actual start", "Change risk", "Epic Status"] def customFieldMap = [: ] //Get all the fields in the system def fieldIDs = get("/rest/api/3/field") .header('Content-Type', 'application/json') .header('Accept', 'application/json') .asBinary() def inputStream = fieldIDs.rawBody