Forums

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

Parse Issue Keys from Custom Field

Christian
Community Champion
April 23, 2024

Hello All

I have a custom field on an issue that contains multiple issue keys separated by commas. The field looks something like "Key-1, Key-2, Key-3". I want to write an automation that will parse out the issue keys and then link the trigger issue to the issues with keys from the custom field. Is there a slick way to do this?

Thanks,

Christian 

2 answers

0 votes
Heenaben Sardarbhai Chaudhary April 23, 2024
Hi @Christian ,
yes you can achieve this, for that you have to use Automation and some scripting.Here's a high-level example of how you might implement this using Jira Automation:
Trigger: When an issue is created or updated.
Action:  Use a script to extract the issue keys from the custom field.Iterate over the extracted issue keys.
For each extracted issue key (Use the Jira REST API or a Jira Automation action to link the trigger issue to the issue identified by the key.)

Thanks,
Heena Chaudhary. 



0 votes
Kalyan Sattaluri
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.
April 23, 2024

Hello @Christian 

 

Does the field have just this list of keys or do you have to extract these from the field? What I mean is, is your field like:

customfield_11 = key-1, key-2, key-3 .. or

customfield_11 =

Some text..... then your keys

key-1, key-2, key-3

then some more text

 

Please share a screenshot of a sample issue with this field populated.

Christian
Community Champion
April 23, 2024

it is as is in your first example. Only the keys in the field:
Screenshot 2024-04-23 101100.png

Kalyan Sattaluri
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.
April 23, 2024

Hello @Christian 

If your field is set up as shown in screenshot,

you can split them by comma and link them to your trigger issue.

Smart value to use is like below:

{{#Time in Development.split(", ")}} {{.}} {{/}}

My recommendation is to log values after the trigger, before linking so you know you are parsing it correctly.

Please see my screenshot I am using Text 2 is my example, you will replace it with your field.

image.png

Hope it helps and accept answer if it solves your issue.

Like # people like this
Bill Sheboy
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.
April 23, 2024

Hi @Christian 

Adding to Kalyan's suggestions...

Something to consider for a scenario like this is context and edge cases:

  • What problem are you trying to solve by doing this?  That is, "why do this"?
  • When do you want this linking to happen: at issue create, when the field changes, etc.?
  • What do you want to happen if that field changes?
  • What do you want to happen if the issue keys listed in the field are not valid?
  • What do you want to happen if the issue keys listed in the field are in a different project scope than the rule?
  • What do you want to happen if someone manually changes the issue linking?
  • etc.

Please pause to consider these questions, and your answers, as they may impact the results versus what you expected for this scenario.  Thanks!

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events