I want to fetch two field the ticket creation date and the closure date which is a custom field

ABDUL_AZIZ_SALIM_BASHA_SHAIKH November 5, 2019

Field1 - Creation Date

Field 2 - Closure Date

*****************************My Script**************************

// Define a JQL query for the issues on which you want to copy custom field values
def query = 'project = ATIT'

// Here you can specify the names of the fields you want to copy from and into
def sourceFieldName = 'Ticket Initiation Date'
def targetFieldName = 'Ticket Closure Date'
// We retrieve a list of all fields in this JIRA instance
def fields = get("/rest/api/2/field")
.asObject(List)
assert fields.status == 200

List<Map> allFields = fields.body
// Now we lookup the field IDs
Map sourceField = allFields.find { it.name == sourceFieldName }
Map targetField = allFields.find { it.name == targetFieldName }

assert sourceField : "No field found with name '${sourceFieldName}'"
assert targetField : "No field found with name '${targetFieldName}'"

println(sourceField);
println(targetField);

 

****************************************************************************

 

Output

GET /rest/api/2/field asObject Request Duration: 700ms
[id:customfield_10100, key:customfield_10100, name:Ticket Initiation Date, custom:true, orderable:true, navigable:true, searchable:true, clauseNames:[cf[10100], Ticket Initiation Date], schema:[type:datetime, custom:com.atlassian.jira.plugin.system.customfieldtypes:datetime, customId:10100]]
[id:customfield_10109, key:customfield_10109, name:Ticket Closure Date, custom:true, orderable:true, navigable:true, searchable:true, clauseNames:[cf[10109], Ticket Closure Date], schema:[type:datetime, custom:com.atlassian.jira.plugin.system.customfieldtypes:datetime, customId:10109]]


******************************************************************************************

I want to calculate the turn-around of the ticket which will be third field.

TAT = (Ticket Closure Date - Ticket Creation Date)

How can query the results in the project and perform calculation

 

0 answers

Suggest an answer

Log in or Sign up to answer