Working time counter
Hi,
We want to know how much time we spend working at an issue.
How can we make, with a workflow, a new field that count, since the issue was created, the time in days (considering 8 working hours a day and excluding Saturday and Sunday) when the issue is in state OPEN + IN PROCESS?
Please sign in to leave a comment.
Hi,
Unfortunately, this cannot be applied to previous operations. I mean, you cannot fetch this data for existing issues, you can only start counting days since now.
To implement the process, follow these steps:
1. Create fields which will store the timestamp of state change (e.g. "SubmittedToOpen", "OpenToFixed"). You need such fields for each transaction you'd like to track.
2. Create an on-change rule (https://www.jetbrains.com/help/youtrack/standalone/Workflow-Rules.html#on-change-rules) which will trigger on issue state change (ctx.issue.isChanged(ctx.State))
3. Find out the old and the new values of State field (use oldValue() and becomes() methods; https://www.jetbrains.com/help/youtrack/standalone/v1-Field.html#becomes; https://www.jetbrains.com/help/youtrack/standalone/v1-Field.html#oldValue)
4. Store current timestamp (Date.now()) to the corresponding field
Having dates of states changes, you can easily calculate the number of days spent in a particular state.
Another option is to create an on-schedule rule (https://www.jetbrains.com/help/youtrack/standalone/Workflow-Rules.html#on-schedule-rules) which will run once a day and increase the counter of days if the state is still unchanged.
Hope it helps.
Hi,
Thank you for answering, you have been very helpful.
But I still have a doubt.
How can I exclude Saturday and Sunday from the counting of the days?
Thanks in advance.
You can check which day it is in the rule. Please feel free to use getDay() method - it returns the number of the day in a week.