Menu

EN | ES

Block issue creation in archived Jira projects

Álvaro Aranda
Jul 14, 2016 9:11:00 AM

Jira projects don't have an end date, but it's common for users to expect a due date after which you don't want anyone to create more issues for that project. In this article we'll going to show how to solve this problem with date custom fields. 

As we said, Jira doesn't have any project-date restrictions, but this is something you don't have to worry about anymore.

Creating a project date field for the project

First of all, be sure to download Projectrak from the Atlassian Marketplace. Once it's running, access the Field Manager on the administration Jira options, where you'll find the app section, and then create a date field.

You'll find different options for the creation of different types of fields; this is the core of Projectrak (formerly Profields) and it can get a bit complex. However, in this situation we only need the one that specifies Dates.

Once the date field has been created, associate it to your Projectrak layout in the Layout Manager, just below the Field Manager. This layout must be associated with your project, and there are two places where you can do that:

  •    In the project administration options
  •    Using the Associate option on the Layout Manager.
Layout manager with project date field for Jira

Once the date field has been created, it's time to give the chosen field the desired value. In this case, it's the end date of your project.

Setting up Jira's project fields


Creating a Projectrak validator

Despite having set the end date in our project, issues can still be created there. That's precisely what we want to avoid. That's why we need a Projectrak validator:

Creating jira projects validator with Profields
As the screenshot shows, it's necessary to get into our project workflow, once there, select the Projectrak Script Validator.

A second validator is needed: the Projectrak Value Validator, which allows to compare values with an equal or not-equal comparator 

In this case, we'll use a "greater" comparator that includes from "today" until the end-date of the project.

This script will do the work for you:

import com.atlassian.jira.component.ComponentAccessor
import com.deiser.jira.profields.api.field.Field
import com.deiser.jira.profields.api.field.FieldService
import com.deiser.jira.profields.api.field.date.DateField
import com.deiser.jira.profields.api.value.ValueService
def END_DATE_FIELD_ID = 3
def project = issue.projectObject
def fieldService = ComponentAccessor.getOSGiComponentInstanceOfType(FieldService.class)
def valueService = ComponentAccessor.getOSGiComponentInstanceOfType(ValueService.class)
def field = fieldService.get(END_DATE_FIELD_ID)
def endDateFieldValue = valueService.getValue(project, (DateField) field)
if ((endDateFieldValue).before(new Date())) {
throw new Exception("The project is closed, you cannot create more issues on it.")
}

 

How to create project dates field? Jira projects with profields

Test goal!!

Now it's time to test all we've done.

How will you know if it's broken? By creating an issue outside the valid date ranges for the project, if the issue appears in the project, something is not working as it should. Here's the example:

Testing jira projects

Yes!!! We usually don't like error messages, but we do love this one. The same problem could also be solved with a list field with "Open" and "Close" as values, for example.


Enhance Jira for project management 


Learn what's the best practice to transform Jira into a project tracker, and start making your life easy at work.

READ THE ARTICLE

No Comments Yet

Let us know what you think

Subscribe by Email