Description
Returns if the project is expired based on the remaining time or in the expiration date
Configuration
1. Create a Projectrak Duration field called "Pack Size".
...
Info |
---|
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
Code Block | ||
---|---|---|
| ||
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" |
...