Page History
Table of Contents | ||
---|---|---|
|
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"
:
Code Block | ||
---|---|---|
| ||
# 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
Incoming Links | ||||
---|---|---|---|---|
| ||||
Related Usage Examples
Content by Label | ||||
---|---|---|---|---|
|