Set field value at creation, based on max field value

I have a field, "Name", that I'd like to set automatically when an issue is created.  The values of this field will be in the form "Acme101623":

  • "Acme":  This is the same for every issue
  • "1016":  This is the current month and year.
  • "23":  This is a sequential number, starting at "01" at the beginning of the month, then will increment by 1 each time an issue is created.

So, for the next issue, I'd need to see all other issues where this field is "Acme1016nn", then increment the highest "nn" value by one to find the next value.  How can I do this?

Thanks,

-Scott

1 answer

0 vote

You'll need to write code to do this.  I'd keep it as simple as possible - a post-function that puts your data into a standard "read only custom field" (Those are intended to be populated by code).  As usual, I'd do it with the Script Runner, but creating an add-on to contain the post-function would work fine too.

The Acme, month and year are quite easy to do.  The sequential number is a bit more of a problem.  You'll need to store that number somewhere, which isn't that hard (active objects if you're coding your own add-on.  Script Runner, I'm less sure of), but you could run into "fun" with concurrency when two users are creating issues at much the same time.

Before you dive into piles of code though, could you explain the requirement from the users point of view though?  There might be a better way to meet the need.

 

I'm migrating our asset tracking database to Jira.  This is the machine name, which follows this structure.  In the old system (a spreadsheet) it was easy to see what the most recent value of this field was and pick the next one.  

I'll look into script runner. 

Thanks,

-Scott

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

81 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you