[Automate] Send email with issueKey when a ticket is being deleted

agnes BOURLON April 6, 2024

Hi All

I created an automate that is trigged when a issue is being deleted.

My aim is to block the deletion or at least send an email with the reporter name and issuekey when the ticket contains a label "obj_test"

I chose the option : 

(x) Execute this rule immediately when the rule is triggered, instead of in the background


 

I thought that it will be possible to check if the ticket has a specific label , and send an email with the key and the reporter and so on....

But, it's not the case as my automate failed saying that the issueKey doesn't exist !

 

This occurs in the JQL that check if the issue contains a specific label 

This step is an "If Issue matches JQL, included" created a Branch Rule ("For Current issue") 

 

To debug it I sent an email first, and then, I put the branch rule and send again an other email. The first email is working properly but the error occurs after.


Successfully sent email.
XXXXX-11157

JQL condition

No subsequent actions were performed since JQL condition did not pass due to error running JQL:
"(key IN (XXXX-11157) AND (labels in (obj_test)))" - An issue with key 'XXX-11157' does not exist for field 'key'.

Could you help me to understand my issue? 
Many thanks in advance,

Best regards

Agnes

2 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.
April 6, 2024

Hi @agnes BOURLON 

An automation rule triggers after an event has occurred, such as Issue Deleted, and thus:

  • a rule cannot prevent the deletion, as it has already occurred
  • the issue is now gone and some of its data may not be available after the deletion.

When I tested with issue delete and a Jira Cloud rule, the reporter and label were still available while the rule was executing.  This may be different for Jira Data Center.

Seeing the specifics of your rule and audit log may explain what you are observing.

Kind regards,
Bill

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 6, 2024

Hi Agnes,

Can you please share the actual rule? It's hard to follow with just the text. 

agnes BOURLON April 7, 2024

Thanks @John  and @Bill Sheboy 

Here are the different steps of my workflow :

workflow.png

First step : Issue Deleted

Step Delete.png

2nd step : Email => OK

Step Email &.png

3rd step : If => KO

Step if.png

Here I got the error :

image.png

Please note that I got the same issue by moving the "If step" before sending the email

It seems that the key is available in the "email step" but not in the "check label step"....

image.png

If the quality of the pictures is not KO, tell me , I can capture other ones

Thanks in advance for your precious help

Agnes

Like John likes 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 7, 2024

I wonder if some conditions (such as JQL condition) do not work on deleted issues because they actually run against the database's issue data rather than the issue data in the rule.

Please try removing the branch on current issue, and then testing the trigger issue smart values directly using the advanced compare condition rather than using the JQL condition.

 

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 8, 2024

I suspect Bill is correct. 

Also, another note - just don't let people delete stuff on that project. 

And if you have to, just get an email every time it happens so you can assess the extend in quick issues are getting deleted because deleting issues is not a good practice. 

Like Bill Sheboy likes this
agnes BOURLON April 12, 2024

Hi @Bill Sheboy 

Sorry for the delay. Here my answer. I added a If "Advanced Compare Condition"

Not sure of my script. This is the first time I use smart value.

Is it correct ? I saw sometimes samples with an "#" before issue.labels

I received the first email but the next one. And I have no issue in the audit log...

In my first mail I can get the information on the ticket (*) included the labels !

Thx in advance

Best regards

Agnes

"image.png

(*) 1st email, I got this result

image.png 

Objet : Deletion

Hello ,
XXXX-11233 // TEST - 2 // obj_test

 

@John Funk

Our admin team doesn't want to change the commun roles created on the projet. And I can't get the rights I need without the deletion right... 

Like Bill Sheboy likes 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 12, 2024

Yes, that will work. 

You could also try using the Issue Fields Condition as that will be simpler.  I tried both with Jira Cloud and they worked, so it is likely the same for Data Center.

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 13, 2024

Two thing - Your example above has text in the email create that does not appear in the sample you provided, so I am assuming you modified it before the test (or afterward). 

Second, your admin team should not let anybody be deleting issues except maybe Jira Admins at best. That's my opinion but something important is going to get deleted some day, and it should be on their heads if they let it happen. 

Oh, third thing - Glad you got it working!! And thanks, @Bill Sheboy !!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer