Auto increment a custom field on Jira cloud

Dheeraj Singh February 23, 2023

Hi Experts,

I have created a text custom field and want that to auto incrment automatically after every jira story is created.

For e.g if the first jira story has fieldvalue as PD1, the next jira story automatically gets PD2

I am using Jira cloud

1 answer

1 accepted

4 votes
Answer accepted
Jens Schumacher - Released_so
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 23, 2023

Hi @Dheeraj Singh 

Welcome to the community!

You can create increment and store a sequence number via Jira automation.

At a high level, you want to store a value with the key "sequence" (or whatever you want to call it) in the properties of the project. With each creation of a ticket, you can increment that value and store it again the issue. 

This is what your automation should look like:

 Screenshot 2023-02-24 at 10.33.48 am.png

Set project property

  • Entity type: Project
  • Property key: sequence (or whatever you want to call the property)
  • Property value:
{{#increment}}{{project.properties.sequence}}{{/}}

The above is an automation math expression which increments the number in between the start "{{#increment}} and the closing tag {{/}} of the expression. 


Edit issue fields:

  • Choose the field where you want to store the value.
  • Access the property via: 
 {{issue.project.properties.sequence}}



Cheers,
Jens

Released.so

Dheeraj Singh February 23, 2023

Hi @Jens Schumacher - Released_so , Thank you for your reply.

I did as you said and the rule is getitng triggered with no error. However still the field which had to autopopulate was blank. I am not sure what i am doing wrong here.

Capture.PNG

 

I had set project property as {{#CRM12}}{{project.properties.ProductCode}}{{/}}

and in the edit issue i had below

Capture.PNG

 

Not sure where i am doing wrong

Jens Schumacher - Released_so
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2023

Hi @Dheeraj Singh 

It looks like you have replaced

{{#increment}}

with

 {{#CRM12}

Not sure what the intention was, but {{#increment}} is critical here as this is the function that will increment the value within the function call. 

Basically, try replacing #CRM12 with #increment

Like Michael Swanson likes this
Dheeraj Singh February 26, 2023

Thanks again  @Jens Schumacher - Released_so . I have replaced that and now i am getting below error 

 

Capture.PNG

New config after replacing #CRM12 to #increment

Capture.PNG

Capture.PNG

Jens Schumacher - Released_so
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2023

Try pasting the string into the "ProductCode" textfield, not "Additional fields" 

Dheeraj Singh February 26, 2023

Thank you @Jens Schumacher - Released_so for patiently answering my queries. I can confirm that the error has been resolved.

Just a last question- Where do i pass the value of the field "productcode". For e.g if i want that to start with PD1 and then increment to PD2 next time. Where do i actually store this value so that it increment automatically with this value

Jens Schumacher - Released_so
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 26, 2023

Hi @Dheeraj Singh 

Please refer back to the first answer. What we are doing here is:

 

  1. Store a number as a project property called "ProjectCode". This has to be a number only and not a string in order for us to increment it when another issue gets created. 
  2. We assign the number to the issue. Here is where you can take that number and add the "PD" prefix. 

 

The second part happens in the "Edit issue fields" step. If you want to add the prefix, all you need to do is to output the number we stored with the prefix in front of it. 

 PD{{issue.project.properties.ProjectCode}}

 
Feel free to mark the comment as Answered if this resolved your question. Thanks!

Like Michael Swanson likes this
Dheeraj Singh February 26, 2023

Thank you for all your help @Jens Schumacher - Released_so 

Hats off to your knowledge, Thanks again

Like Lena.Lawson likes this
Kevin Shea March 6, 2024

This worked perfectly!  If I wanted to start the "sequence" variable at a given number, is there a way to do that?

Vanya Ramirez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 16, 2024

this is great, thanks for sharing!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events