On this page

Use case

Issues can easily be identified by using their issue key. But some use cases also might require some custom IDs, which e.g. contain the current year and a custom number.

We will use project properties to store the current year and a custom number. With the help of the post functions, these two numbers will then be combined as an ID and added to the issue on creation.

 This use case can perfectly be done using JWT's post functions in combination with project properties!


Prerequisites

To get this use case working, several post functions are needed to set up the configuration.

Setting up the project property "currentYear"

Add the Update or copy field values post function to the create transition of the desired workflow.

Target issue

Choose Current issue

Field

Choose Temporary number 1

Value

Choose Parser expression and enter the following expression in numeric mode:

year({system.currentDateTime}, LOCAL)

By using the year() function, we are grabbing the year part from the current date.

For further information, take a look at the year() function page.

Conditional execution

Enter the following expression:

year({system.currentDateTime}, LOCAL) != toNumber(projectProperty("currentYear"))

The conditional execution is needed so that we only update the currentYear property, if the year changed (see below).

Add the Set or create JWT project property post function to the transition.

Property

Enter:

currentYear

Value

Enter:

%{issue.temporaryNumber1}

Action

Choose Create the property and assign the value

Conditional execution

Enter the following expression:

year({system.currentDateTime}, LOCAL) != toNumber(projectProperty("currentYear"))

Like above, we only want to execute this post function (and update the project property), if the current year is different to the one saved in the project property currentYear.

Setting up the project property "counter"

Add the Set or create JWT project property post function below the previously created post functions.

Property

Enter:

counter

Value

Enter:

1

Action

Choose Create the property and assign the value

Conditional execution

Enter the following expression:

year({system.currentDateTime}, LOCAL) != toNumber(projectProperty("currentYear"))

This way the counter will be reset to 1, if the year changes e.g. from 2021 to 2022.


Configuration

Writing the ID to the issue

Add the Update or copy field values post function underneath the created post functions.

Target issue

Choose Current issue

Fields

Field

Choose the field you want to set with the ID

Value

Choose Parser expression and enter the following expression in advanced text mode:

projectProperty("currentYear") + "-" + substring("0000", length(projectProperty("counter")), 4) + projectProperty("counter")
more info...

In our use case, we want to set the current year combined with a 4-digit number as ID.

The expression

substring("0000", length(projectProperty("counter")), 4)

takes the length of our counter and dynamically adds zeros to fill up the counter to a 4-digit number.

Example:

"counter" project propertyAdded zerosOutput
130001
1020010
10010100
100001000

Field

In addition, select Temporary number 1 field.

Value

Choose Parser expression and enter the following expression in numeric mode:

toNumber(projectProperty("counter")) + 1

We increase the Temporary number 1 by 1 to increase the counter project property (see below).



Increasing the counter

Add the Set or create JWT project property post function.

Property

Enter:

counter

Value

Enter:

%{issue.temporaryNumber1}

Action

Choose Create the property and assign the value


Screenshots



If you still have questions, feel free to refer to our support team.