Create a new issue and assign unique number/text to custom field

yanivlt January 2, 2024

Since at our product is subjected to strict regulation and since we already have our requirements written on other platform (we want to migrate), every requirement must have a unique id, on top of the Jira Key.

So we are going to have a custom field named SR_ID.

Whenever a new SR issuetype is created. we'd like to assign it a unique text/number in format of XX-XXXXXX.

is it possible using automation / script?

2 answers

1 accepted

2 votes
Answer accepted
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 2, 2024

Yes I think so but the following is a bit of a hack. As well, given you are on Free tier then you may exhaust your allotment of Automation rules. Finally, let's discuss the xx-xxxxx bit. Let's rewrite as AA-xxxxx where AA will be static similar to how Jira uses ABC-123 where ABC is the project key and 123 is a sequential number incremented with each new issue created. Assuming the aforementioned is accurate then you would create a rule for each "AA" category And simply increment the xxxxx sequentially.

given the above here is my recommended solution:

  1. Create an issue, that will be the reference issue Used as a means of determining the latest sequential number. What you will do is have a custom field, let's call it latest-SRID, associated with that specific issue.
  2. Create a rule that is triggered each time a new issue is created. 
  3. in the rule you will copy the value of the latest-SRID into a variable. You will use that variable in an edit issue action to set the SR-ID of the issue to be the variable plus 1.
  4. finally in the same rule you will edit the reference issue and increment the increment the latest-SRID

I hope the above gives you some guidelines of how to approach the problem. There are a few different options for actually constructing these rules so I highly recommend reviewing the documentation around incriminating numbers and math expressions as well as variables. If you have any questions, please let me know.

2 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2024

Welcome to the Atlassian Community!

I strongly recommend that you do not implement this.  It's a broken process, both in terms of information handling (why are you giving your humans a reference they're going to have to make a load of effort to use?).  Technically, if you were to automate the creation of an utterly redundant unique ID, you are likely to end up with duplicates, and missing numbers because of the way Automation would do it.  

What is wrong with just using the issue key?  It's guaranteed unique, and gives you the ability to construct URLs to link to it in other systems.

yanivlt January 3, 2024

As explained: strict regulation and since we already have our requirements written on other platform (we want to migrate), every requirement must have a unique id, on top of the Jira Key.

Thanks for the info.

Do you have any idea how to implement?

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2024

I doubt you have regulation that says "you have to format an identifier in a particular way".  You will have regulation that says "your identifiers must be unique".  Which means the Jira key is fine.  Or possibly the id in the database, as that won't change if you move an issue from one project to another.

It sounds like your existing requirements have this unique id as an identifier.  I would import that ID into the "external ID" field, and then forget it, using the Jira key for new ones.

Suggest an answer

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

Atlassian Community Events