Forums

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

How can I extract the numeric part of issue key?

Zaldy Parian
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.
July 5, 2023

Hi all,

Hope someone can help me with my question.

I got a requirement where the service desk tickets: Incidents/Service Requests/Problem, would carry its own issue key. For example an incident ticket will have INC-123; and a service request ticket will have SR-124 and so on. And all tickets in just one project. 

I created a custom field to store "INC" or "SR" or "PB" based on issue type. Then I created an automation with IF/ELSE conditions when issue is created. The automation is to add a suffix on the Summary field as "PRJ-123INC-Short summary of incident". Where:
- PRJ is the project key
- 123 is the key sequence number
- INC stands for incident
- and the rest is the text in Summary field.

But the business wanted to have PRJ to be replaced with INC in the Summary field. What will be the smart value to extract the numbers in the issue key and prefix it with the custom field I created? I gone as far as... {{customfield_10221}}-((issue.key}} , but this also takes the PRJ part.

Regards,

3 answers

3 accepted

1 vote
Answer accepted
Evgenii
Community Champion
July 5, 2023

Hi, @Zaldy Parian 

I think, the best way will be using split function. Key - it's a simple string, that looks like ZZZ-123, where ZZZ is project key, and 123 - index number.
So, if you'll use something, like this:
{{issue.key.split("-").first}} -> ZZZ
{{issue.key.split("-").last}} -> 123
you'll receive demanded values.
Zaldy Parian
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.
July 6, 2023

Thanks for your help and guidance. This option addresses my inquiry.

1 vote
Answer accepted
Ajay _view26_
Community Champion
July 5, 2023

Hi @Zaldy Parian 

You can use something like - {{issue.summary.replaceAll('([A-Z]+-\\d+)', 'INC-$1')}} 

Refer - https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/

Zaldy Parian
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.
July 6, 2023

Hi Ajay_view26_

Great stuff. thanks.

0 votes
Answer accepted
Joseph Chung Yin
Community Champion
July 5, 2023

@Zaldy Parian -

Take a look at the following link on dealing with text parsing for automation - https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/

Hope this helps.

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Technology Applications Team

Viasat Inc.

Zaldy Parian
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.
July 6, 2023

Thanks for your help and guidance. This is also a good option to my inquiry.

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