Forums

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

How to automise issue links based on a URL field?

Hannah Sorrell October 3, 2024

Hey, I have created a URL field in my form where people paste in the URL to the jira task they would like linked. 

How can I automise this? 

I have included some screenshots of where I need help :) I have set it up so that when an issue is created and the 'er knyttet til en annen oppgave?' is not empty then the edit issues field is edited. I then want the URL from this field to be used so that it knows which issue to link. 

Hoping this makes sense :) 

Skjermbilde 2024-10-03 kl. 15.28.33.pngSkjermbilde 2024-10-03 kl. 15.28.44.png

3 answers

0 votes
Gabriel Viger February 4, 2025

Here's how to do it:

Replace trigger and conditions to match your scenario.

Screenshot 2025-02-04 at 13.44.30.png

0 votes
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.
October 3, 2024

Hi @Hannah Sorrell -- Welcome to the Atlassian Community!

You could use text functions to extract the issue key from the URL in the custom field, and then use that in the Link Issues action: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/

For example, the issue link URL probably looks like this:

your Jira URL/TEST-123

And so the key may be extracted with:

{{issue.yourCustomField.substringAfterLast("/")}}

That will work if the field is plain text.  If it is a smart link, use this:

{{issue.yourCustomField.substringAfterLast("/").substringBefore("]")}}

 

Kind regards,
Bill

Hannah Sorrell October 4, 2024

Thanks Bill! Could you explain this a little more? 
It is possible to ask people to write the issue number, for example TEST-123, instead of the URL. 

However I have not managed to automate linking of tasks yet. 
Here is what I have just tried :) 

Skjermbilde 2024-10-04 kl. 11.23.34.pngSkjermbilde 2024-10-04 kl. 11.21.30.png

Hannah Sorrell October 4, 2024

Here is what happens when I create a text field in the form instead of a URL: 

Skjermbilde 2024-10-04 kl. 11.32.26.pngSkjermbilde 2024-10-04 kl. 11.32.22.pngSkjermbilde 2024-10-04 kl. 11.32.06.png

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.
October 4, 2024

First thing, when using the Issue Created trigger, it can fire so quickly that some data may not yet be available to the rule...potentially causing unexpected behaviors. 

The fix for that is to always add the Re-fetch Issue action immediately after the trigger, to slow down the rule and re-load the data:

  • trigger: issue created
  • action: re-fetch issue
  • ...

 

Next, smart values are name, spacing, and case-sensitive.  When an incorrect one is used it returns as null.  I recommend pausing to confirm the correct smart value (or custom field id) for your field using this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Finally, if your team members may enter just the issue key or enter a URL, the rule will need to handle both cases.  Is that accurate?

You may want to create a variable for the expected key and then use a condition to test it.  For example:

  • action: create variable
    • name: varIssueToLink
    • smart value: {{issue.yourCustomField.substringAfterLast("/")}}
  • if / else condition  (Check if the variable is empty, and if so replace it with the complete field.)
    • smart value condition:
      • first value: {{varIssueToLink}}
      • condition: equals
      • second value: leave this empty
    • action: create variable
      • name: varIssueToLink
      • smart value: {{issue.yourCustomField}}
  • action: link issue, using {{varIssueToLink}} as the key

 

0 votes
Jovin
Community Champion
October 3, 2024

Hey @Hannah Sorrell 

Great question here, and meanwhile I'm unsure whether the URL can be used to link it you can always give it a try by using the "Link issues" action alongside the smart value for the field. That dropdown can also have values typed in.

To access the field you've created use {{issue.Field Name}}, in this case for your example you'd put in {{issue.er knyttet til en annen oppgave?}}

It may not work with URLs, but worth a shot!

Hannah Sorrell October 3, 2024

Thank you so much, I gave this a try but unfortunately had no luck. 

Something interesting is, even when I have the value set to 'trigger issue' or 'most recently created issue' I still don't get an any tasks linked. So I wonder if there is something else wrong with my automisation rule also? 

Suggest an answer

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

Atlassian Community Events