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

Automatic subtask change status depending on another subtask status

HI I have   six subtasks. A B C D E F

If C is rejected. I want to change tghe status of D E and F to rejected.
If D is rejected. I want to change tghe status of C E and F to rejected.
If E is rejected. I want to change tghe status of C D and F to rejected.
If F is rejected. I want to change tghe status of C D and E to rejected.


I don't have idea how to do it ussing scriptrunner.
Anyone have an example or document to do it?

Thanks in advance.



1 answer

Hi Sergio.

You could do this with a custom listener, or with a custom post function.

In this article you will find a bit of information on how to autoclose subtask. You would need to do something similar, but with a resolution like "rejected".

If you do need further help let me know.

Cheers!

Dyelamos

thanks  for your help. @Daniel Yelamos [Adaptavist]

I don't want to change the resolution. I need to change the status of some subtask , not all.


I need to do how to ask if the parent have subtasks and if these subtasks are C D E issuetypes.
then of one of these C D or E are in reject status, the others subtask C D or E move to rejected status automatically.


thanks again.

Sergio, first of all, you are contradicting yourself in both of your comments.

In the first comment you state that:

"I have six subtasks. A B C D E F"

But then in your other comment you say that 

"If these subtasks are C D E issuetypes."

Aren't A B C D E and F subtasks?

 

------------------------------------------------

Secondly, my personal recommendation is that you go through all of our documentation bit by bit and you learn how to set a post-function for scriptrunner and the different things you can do. You will find a lot of information in this community and in our documentation site. 

----------------------------------------------

Finally answering your specific questions:

What you would need to use to fix your issue, is a custom post function that is set in the "close" transition. This postfunction would be triggered every time you close a function in your project, only if the issue is a subtask. I don't exactly know what you mean by your A B C D E and F subtasks, if they are types, then:

1. Within that postfunction, you need to determine if your task is a subtask or not, in order to do that you can use:

issue.getIssueType().isSubtask()

Which should return a boolean. If it isn't a subtask, don't do anything.

2. If it is a subtask, then check the issueType name, to make sure that it is within your domain [A...E]

if(issue.getIssueType().name == "A")

 For A, for example.

After that, if it is one of your types, apply the main logic of your program.  

3. To get the parent of your subtask you can use:

MutableIssue parent = issue.getParentObject() as MutableIssue

4. To get the rest of the issues within your parents, you can use:

parent.getSubTaskObjects()

To transition the rest of the issues to closed, you can use the link I sent you previously.

-------------------------------------------

I hope this helped. Good luck with your scripts!

Cheers!

Dyelamos

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

22 views 0 2
Read article

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