Document toolboxDocument toolbox

(8.5.1) Expired project

Title

Expired project

Description

Returns True if the project expiration date has passed or the remaining time has been consumed, otherwise returns False 

Objective

Identify if your project has expired based on two conditions:

  • If the Total Time Spent of the project is greater than the project estimate (Pack Size)
  • If the Expiration Date field is before today
Audience
  • Service managers
  • Project managers
What does a Jira Project Represent?It represents a customer support project
Focus

Projects or support tracking and monitorization

Configuration

1. Create a Projectrak Duration field called "Pack Size". 

2. Create a Projectrak Cumulative field called "Total Time Spent".

3. Create a Projectrak Date field called "Expiration Date".

4. Create a Projectrak Script field called "Expired project".

5. Insert the following Groovy script and modify according to your instance into "Expired Project" field:

Pre-requisites:

  • Projectrak Duration field called "Pack Size"
  • Projectrak Cumulative field called "Total Time Spent"
  • Projectrak Date field called "Expiration Date"

Description: Returns if the project is expired based on the remaining time or in the expiration date

Use in: It should be used as a Projectrak Script field

Variables in context: 

  • project [com.atlassian.jira.project.Project]: The current project


PACK_SIZE_FIELD_ID: Line 12 in the script. In the example we are using 122. Please use the ID that corresponds to your Duration field

TOTAL_TIME_SPENT_FIELD_ID: Line 13 in the script. In the example we are using 82. Please use the ID that corresponds to your Cumulative field with total Time Spent

EXPIRATION_DATE_FIELD_ID: Line 14 in the script. In the example we are using 12. Please use the ID that corresponds to your Date field with the due of the project


Groovy Script

expired-project.groovy
package deiser.profields.scripts


import com.atlassian.jira.component.ComponentAccessor
import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.field.cumulative.CumulativeField
import com.deiser.jira.profields.api.field.date.DateField
import com.deiser.jira.profields.api.field.duration.DurationField
import com.deiser.jira.profields.api.value.ValueService

// Configuration
def PACK_SIZE_FIELD_ID = 122
def TOTAL_TIME_SPENT_FIELD_ID = 82
def EXPIRATION_DATE_FIELD_ID = 121

// Components
def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class)
def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class)

// Get the fields
def packSizeField = fieldService.get(PACK_SIZE_FIELD_ID)
def totalTimeSpentField = fieldService.get(TOTAL_TIME_SPENT_FIELD_ID)
def expirationDateField = fieldService.get(EXPIRATION_DATE_FIELD_ID)

// Get the field values in the current project
def packSize = valueService.getValue(project, (DurationField) packSizeField) ?: 0
def totalTimeSpent = valueService.getValue(project, (CumulativeField) totalTimeSpentField) ?: 0
def expirationDate = valueService.getValue(project, (DateField) expirationDateField)

// Conditions
def timeConsumed = packSize <= totalTimeSpent
def expiredDate = expirationDate ? expirationDate <= (new Date()).previous() : false
def isExpired = timeConsumed || expiredDate

// Returns true any of the conditions is passed

return isExpired?"TRUE":"FALSE"


6. Configure the project's layout including all of the fields created.

7. Associate the Layout to the project you need this information to be applied to.

8. The result should be something like this: (please, keep in mind that this is only an example and your results should vary from what it is shown in the screenshot).