automation for deleted items

Eran Roiter
Contributor
December 31, 2024

Hey all,

I have linked issues in my Jira project, and i want to make sure once issue deleted, and this issue have a linked issue with the main issue link connection.

The status of the linked issue will change back to Open / New.

 

The problem is, once issue delete it is "lost"
and I'm getting this message: 

 

 

"issue in linkedIssues("PLT-5318","Main Issue")" - Issue 'PLT-5318' could not be found in function 'linkedIssues'.
Any ideas how i can perform this action / automation?
image.png

Thanks !

3 answers

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.
December 31, 2024

Hi @Eran Roiter 

There are challenges when rules with the Issue Deleted trigger try to access any related issues:

  • things like branch to parent no longer work as the connection may already be removed
  • same challenge for branching to linked issues
  • using a JQL branch will not work because behind the scenes, rules automagically add a clause to exclude the trigger issue and it is gone now...leading to a rule error.  For example, they add AND ( key != {{triggerIssue.key}} )
  • etc.

 

For the rule you show, I can think of two possible workarounds:

  • use two rules
    • create a second rule with an Incoming Webhook trigger, and this rule will branch over the linked issue keys with a JQL branch, passed as a parameter
    • keep your current rule, and instead of branching to the linked issues, call the second rule using the Send Web Request action using its URL and passing the linked issue list from {{triggerIssue.issuelinks}} and use smart value, list filtering to only send the ones for the type needed
  • use one rule
    • rather than branching to the linked issues, use the {{triggerIssue.issuelinks}} filtered to the type you need to get the keys, and feed them to an advanced branch
    • the advanced branch will not see them as issues, and so the rule will now need to repeatedly call various REST API endpoints to get the issue, make updates, etc.

I recommend the two rule approach as it will be faster and easier to maintain, even though it may be more difficult for others to understand.

Kind regards,
Bill

Eran Roiter
Contributor
January 2, 2025

Hey Bill,

 

Thanks for your comment, can you show an example of the two rules option?

I'm not sure i understand how to do so.

Thanks !

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.
January 2, 2025

Please note well: chained rules like this can be difficult to build, so I recommend testing thoroughly before performing any actions that cannot be reversed.

For example, you could change the first rule trigger to manual and replace actions (such as Send Web Request) with writes to the audit log until you have confirmed the correct issues are being found for processing.

On to the how-to information...

 

First, disable your current rule, as you may copy it as a starting point for the other two rules.

 

The second rule could look like this.  This one is created first so you have the generated webhook URL.

  • trigger: incoming webhook, with this option selected
    • Issues provided in the webhook HTTP POST body
    • Read the information in the trigger to learn how to pass the issue keys in the new first rule
  • ...put the steps that were in your branch in the original rule

The new first rule could be:

  • trigger: issue deleted
  • condition: issue type is Epic or Initiative
  • condition: linked issues present for "Main Issue" type
  • action: create variable, to get the list of keys needed.  Please test / verify that this matches your links before the next rule step, including the direction of links: inward versus outward.
    • name: varLinkedIssues
    • smart value:
{{#issue.issuelinks}}{{#if(equals(type.outward, "Main Issue"))}}{{outwardIssue.key}},{{/}}{{/}}
  • condition: check that {{varLinkedIssues}} is not empty
  • action: Send Web Request
    • where the URL is the one from the webhook in your second rule
    • and the data is the list of issues from filtered list of links
{
"issues": {{varLinkedIssues.substringBeforeLast(",").split(",").asJsonStringArray}}
}

 

0 votes
Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 31, 2024

Hi @Eran Roiter 

When an issue is deleted, everything linked to it is lost. Every link for any linked issues is deleted.

Example. JIRA-1 is linked to JIRA-3. link is related to. If I delete JIRA-3 that link will be deleted from both sides.

Hence why you get the automation error.

You will need to find another way to move the status.

> The status of the linked issue will change back to Open / New.

Try an automation to monitor when an issue link is deleted. then move the ticket to the status you need.

Regards

Aaron

0 votes
Wojciech Wardaszko _HeroCoders_
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.
December 31, 2024

Hi, @Eran Roiter 

Unless these issues are being deleted in bulk, I'd just make an automation rule that would be manually triggered by the users from the Actions menu, so the trigger would be Manual.

Then do all you need to do on the linked issue, and as the last step, delete the trigger issue.

The remaining challenge is to get the users to use the Action instead of the Delete issue menu option. 

Eran Roiter
Contributor
December 31, 2024

Hi, thanks for the answer, Maybe I wasn't clear, there are tickets that are linked to a deleted ticket, their link with a certain status, which brings up the window that asks to add the LINK ISSUE What happens is that once the "main" ticket is deleted. The rest of the tickets remain in the same status, they aren't returning "back" to a New / Open status.


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