Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Send notification to next sub-task assignee

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

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

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

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

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?

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.

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

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

@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!

@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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you