Rule for close a subtask only when the registered time its superior to 0
Asked by Enmanuel Vignoli:

my principal idea was to use the Issue Transitioned trigger, then set a branch for Subtask and add a condition with time traking \> 0 with a For in For  
![Screenshot_5.png](https://community.atlassian.com/t5/image/serverpage/image-id/332468iB990B7FDE2F0E42E/image-size/large?v=v2&px=999 "Screenshot_5.png")![Screenshot_6.png](https://community.atlassian.com/t5/image/serverpage/image-id/332469iF8F582392E461ABA/image-size/large?v=v2&px=999 "Screenshot_6.png")


Answers:
author: Trudy Claspill
body: Hello [@Enmanuel Vignoli](/t5/user/viewprofilepage/user-id/5531817)

Welcome to the Atlassian community.

If you want to evaluate the amount of time logged against an issue you need to use this smart value:

{{issue.timetracking.timespent}}

...not this smart value:

{{issue.timetracking}}

Which issue are you trying to affect with the second branch? Are you trying to affect the subtask or the parent of the subtask?

![Screenshot 2024-06-28 at 10.45.30?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/332471i419A5BF82CC1FDF9/image-size/large?v=v2&px=999 "Screenshot 2024-06-28 at 10.45.30?AM.png")

The way the rule is currently written it will be triggered when an issue of any type transitions to Done.

Next it will step through the Subtasks under that issue. If there are no subtasks then no actions will be taken.

For each subtask I assume that you want to check if time has been logged against the subtasks.

I am unclear what you want to do after that. I can tell that you want to check the Status Category of the Status assigned to an issue, but I am not sure which issue you want to apply that to. It appears that if the Status Category is Done then you want to add a comment to the same issue.

comments: author: Enmanuel Vignoli
body: Hello!  
I'm just trying to affect the subtasks.  
The purpose of the rule is that when the user wants to finish a subtask, it must have a minimum amount of time registered in it to be able to move to the "Done" state. If it does not have time registered, it will not be able to go to "Done" in which case the user must be notified by means of an email about it or a comment within the same subtask.


author: Trudy Claspill
body: Thank you for clarifying the requirement.

Be advised that an Automation Rule cannot be used to prevent an issue from changing to another status. The Automation Rule is triggered in response to an event that has already completed. In this case, with the Issue Transitioned trigger, the transition of the subtask to Done is already completed.

If you want to prevent the transition from being completed you have to modify the workflow associated with the subtask issue type.

Are you working with issues in a Team Managed project or a Company Managed project? That information is found in the Type column on the View All Projects page under the Projects menu. The method to modify the workflow depends on the Type of the project.

A Company Managed project workflow can be modified to add a Validator to ensure some time has been logged against the issue.

The workflow configuration for a Team Managed project does not support directly checking for that. A work around would have to be implemented in that case.


author: Enmanuel Vignoli
body: thanks for the reply! its helps me alot!


Tags: cloud

jira-cloud