Send notification to next sub-task assignee

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.
January 26, 2021

Hi all,

We got a parent task with several sub-tasks. Is it possible in Jira Automation to send email notification to the assignee of the next sub-task when the previous task has been transitioned to Done status? How do I check if there is still remaining sub-task to be completed? And then take the assignee to be used for email notification?

Appreciate your help and instructions on how to achieve this.

Thanks,

Zaldy

2 answers

0 votes
Kate Kabir
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 27, 2021

Hi Zaldy

Thank you for the question. 

I would advise you to check the issue object in the issue object which comes in the binding of the post function to get the subtasks for an issue and to get the next one to get the assignee off it. Then you will need to call the notify API to send a notification and I can confirm that the documentation example located here shows how to call this API to send an email and can be used as a reference to create the script that you require.

I hope this will help. 

Thank you 

Kind Regards

Kate

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.
January 27, 2021

Hi @Kate Kabir ,

Thanks for your reply. But I'm not sure I can follow your suggestions. I'll continue to find an easy way to do this.

Cheers.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2021

How are you telling Jira what the "next" sub-task is?

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.
January 26, 2021

HI @Nic Brough -Adaptavist- ,

That's one of my problem, I don't know how to tell Jira if there still remaining sub-task with status not equal to 'Done'.

Any thoughts?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 26, 2021

There's two parts to that.  The easier one is "not done" - a simple search can do that with (pseudocode) "parent = X and status not 'done'".  The hard part is "next" - whilst we could add "order by" to the query to get an ordered list, you haven't defined what that is.

Assuming the order is something easy or obvious like "priorty", a custom field with a definitive order,  "created time" or even "issue key" (which would al make very good sense if you're automatically creating the subtasks - code for that would create them in the same order each time or explicitly set it), then you just read the first element from the result list.

Problem there is that I do not know if Automation can do that.  I know I can code it (because I have) and I'm 99.9% certain anything I can code, Scriptrunner and possibly other apps can also support that code.  Just not sure of Automation here.

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.
January 26, 2021

Thanks for all your suggestions, @Nic Brough -Adaptavist- .

I envy you that you can do it via scripting. Unfortunately, that is not one of my forte. Anyway, I'll continue google-ing to find an answer.

Like Nic Brough -Adaptavist- likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2021

Sorry I can't give you a direct answer to the last bit, I don't know Automation as well as Scripting.

LaurieC July 15, 2021

@Nic Brough -Adaptavist- Do you have an example shared of how you might do this in Scriptrunner based on creation date as the ordering parameter? I'd love to see that!

LaurieC July 21, 2021

@Zaldy Parian I was able to do something similar based on this post and help from @Hyrum Steffensen _Appfire_ (Thank you again Hyrum!)

And now I'm looking to figure out the next subtask and look up the assignee and then reassign the parent to the assignee on that next subtask.

As I was working on the code in the Script Console, I realized that if I changed the order of the subtasks (by dragging and dropping) the script recognized that. So some of the following code might help you, 

import com.atlassian.jira.component.ComponentAccessor

log.setLevel(org.apache.log4j.Level.DEBUG)

def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("OAK-25198")
log.debug "issue is $issue"
def parent = issue.getParentObject()
log.debug "parent issue is $parent"

def subTasks = parent.getSubTaskObjects()

for (int i = 0; i < subTasks.size(); i++) {
def subtaskNumber = subTasks[i].getKey().findAll( /\d+/ )*.toInteger()[0]
log.debug "subtaskNumber is $subtaskNumber"

}

If I run this with the issues out of key sequence, it recognizes that - see  the log below and note they aren't in order. It realizes the subtasks go from 25198, to 25200, to 25199

2021-07-21 15:56:15,930 DEBUG [runner.ScriptBindingsManager]: issue is OAK-25198 2021-07-21 15:56:15,937 DEBUG [runner.ScriptBindingsManager]: parent issue is OAK-25197 2021-07-21 15:56:15,944 DEBUG [runner.ScriptBindingsManager]: subtaskNumber is 25198 2021-07-21 15:56:15,944 DEBUG [runner.ScriptBindingsManager]: subtaskNumber is 25200 2021-07-21 15:56:15,944 DEBUG [runner.ScriptBindingsManager]: subtaskNumber is 25199

Suggest an answer

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

Atlassian Community Events