Features used to implement the example
To implement this functionality we will use two custom fields and two post-functions
- Create a Date Time Picker type custom field called "Work Start Time". In this example the field code for this custom field is {10002}.
- virtual field "Current date and time", the field code is {00057}
.
- Use post-function Mathematical and date-time expression calculator in transition "Start Progress" in order to store current date and time in custom field "Work Start Time".
- Use post-function Log work in transition "Stop Progress" in order to insert a work log for the minutes elapsed between date-time stored in custom field "Work Start Time" and current date and time.
Example: Automatic work log with start and stop work transitions
We want to automatically insert a work log for the time passed since triggering of "Start Progress" transition to triggering of "Stop Progress" transition.
Insert post-function Mathematical and date-time expression calculator into transition "Start Progress" to set custom field "Work Start Time" with the value of virtual field "Current date and time":
Note that:
- {00057} is field code for numeric value of virtual field "Current date and time"
Once configured, transition "Start Progress" looks like this:
Insert post-function Log work into transition "Stop Progress", using a time formula to calculate the number of minutes elapsed between "Start Progress" and "Stop Progress" transitions:
Math expression for obtaining the time elapsed in minutes: ({00057} - {10300}) / {MINUTE}
Note that:
- {00057} is field code for numeric value of virtual field "Current date and time"
- {10300} is field code for numeric value of custom field "Work Start Time". This code is dependent on each particular Jira instance
- When we want a string representation of a date-time field, we use the string value field code, i.e., %{00057} and %{10300}
Once configured, transition "Stop Progress" looks like this:
Alternative implementation
Support for Custom Schedules (since version 2.2.39)
You can also implement the above use case but only considering the actual work time in your organization. To do it you should define your custom work-schedule using Schedules Definition Grammar at Administration > Add-ons > JIRA WORKFLOW TOOLBOX > Schedule
Let's consider the following work-schedule called "
my_work_schedule"
:
# Winter Schedule MON - THU { 08:00 - 15:00, 16:00 - 20:00; } FRI { 08:00 - 15:00; } # Summer Schedule JUN/15 - SEP/15 { MON - FRI { 08:00 - 14:30; } } # Annual Holidays JAN/1, MAY/1, NOV/1, DEC/25 {;} # 2017 Holidays 2017/JAN/12, 2017/APR/13, 2017/APR/14, 2017/NOV/23 {;}
In order to use this custom work-schedule we should use the following configuration in post-function Log work:
Formula is: timeDifference({00057}, {10300}, "my_work_schedule", LOCAL) / {MINUTE}
Other examples of that function
- Automatic work log with start and stop work transitions
- Log absence time on another issue
- Log absence time on another issue
Mathematical and date-time expression calculator
- Automatic work log with start and stop work transitions
- Automatically log work time when the user uses a "Stop Progress" transition
- Calculate the time elapsed between 2 transition executions
- Getting the number of selected values in a custom field of type Multi Select
- Implement a form with a series of questions and calculate a numeric value based on the answers
- Increment a field or set to 1 if it's not set
- Set "Date-Time Picker" custom field with current date-time
- Set "Due date" 6 natural days (or work days) earlier than a "Date Picker" custom field
- Set "Due date" to a specific day of next week no matter of date of creation this week
- Set "Due date" with certain time offset from current date
- Set "Total time spent" to "Current date and time - date and time of last update"
- Set a custom field "Urgency" depending on a combined value of issue's priority and "Impact" custom field
- Sum "Time Spent" in all sub-tasks of issues linked with issue link types "LinkA", "LinkB", "LinkC"
- Triage Jira Service Desk email requests (Move issues)
- Using project properties to calculate custom sequence numbers