Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to autoincrement alphanumeric custom field

ariraati January 9, 2024

Hi,

I have a read only (single text line) custom field Risk_id

What is the best practise to set Risk_id with alphanumberic value in format of R0001, R0002, R0003 at the time of issue is being created?

About syntax R####
* the value always starts with letter R,
* which is followed by autoincremented 4-digit number #### 

If you propose Scriptrunner, please provide  sample code. 

1 answer

1 accepted

0 votes
Answer accepted
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 9, 2024

Welcome to the Atlassian Community!

The best way to do this is not have a separate redundant field for a key.

Why do you think you need a redundant and less useful field than the issue key?

(I know this is a grumpy-looking post, but it really is about looking at your process and data integrity.  Unless you have a legacy system that needs those identifiers that your organisation is imposing on your people because they are afraid of change, then using a redundant duplicate key is utterly pointless)

ariraati January 9, 2024

Point understood, but there is a need for another key for ISO27001 quality reporting and tracking. Secondly in the project there are other issues types (e.g. controls, tasks) so it's not ok Risks only have the standard issue like PR-1, PR-4, PR-12 and so forth. Also this is needed, because the project should be copied to another site and the creation of risks should always start from risk key ID R0001.

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 10, 2024

No there is no need for another key (and it wouldn't be a key anyway, your users would have to waste their time searching for a key because it would never directly identify an issue)

If you want to insist on having different keys for different issue types, then create a new project, with the right key, one for each key you want to use.

This will do two things:

  • Let you have PR, ID, RI, etc as issue project prefixes
  • Will create them sequentially, as the Jira issue number part of the key is sequential
ariraati January 15, 2024

Thanks @Nic Brough -Adaptavist- , actually with the Customer we ended up to create own projects / issue. These projects shall share their project configuration.

Like Nic Brough -Adaptavist- likes this

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