Example: Automatically log work time when the user uses a "Stop Progress" transition
Is it possible to log work using a post-function? Are there any other means of achieving this?
What we want to achieve is to automatically log work time when the user presses the Stop Progress button, either by automatically logging the work time or by setting the time in the Work Time field in the stop progress screen.
Yes, you can do it. You have to use the following elements:
- Virtual field "Total time spent (minutes)". Writing into this virtual field allows you to log time
- Virtual field "Current date and time"
- An auxiliary custom field of type Date Time to store the time where you start progress. In the example I call this field "Start Progress Time"
- Post-function Mathematical and date-time expression calculator to do all the calculations and assignments into virtual field "Total time spent (minutes)"
We only need to insert post-function Mathematical and date-time expression calculator into two transitions: "Start Progress" and "Stop Progress".
Transition "Start Progress": We insert post-function Mathematical and date-time expression calculator in transition "Start Progress" to store into custom field "Start Progress Time" the exact moment when you begin working on the issue. This custom field should not be present in edit screen since you only want it to be modified by this post-function. Let's see in screenshots how to do it:
Once configured, the transition will look like this:
Transition "Stop Progress": We insert post-function Mathematical and date-time expression calculator in transition "Stop Progress" to calculate the true time passed since "Start Progress" to "Stop Progress", and add this time to the value already present in virtual field "Total time spent (minutes)". Let's see how to do it:
Once configured, the transition will look like this:
This solution trims seconds passed since last whole minute, that is, if time passed since "Start Progress" to "Stop Progress" were 35 minutes 22 seconds, logged time would be 35 minutes. I could add a new virtual field "Total time spent (seconds)" to enable a resolution up to seconds.
Since version 2.2.39 you can do the time calculation considering only a particular work schedule, i.e., only the days and times when actual work is done. To do it you should use the following formula instead:
timeDifference({00057}, {nnnnn}, "my_schedule", LOCAL) / {MINUTE}
Where my_schedule is the name of your particular work schedule. You define your schedule using Schedules Definition Grammar at Administration > Add-ons > JIRA WORKFLOW TOOLBOX > Schedule.
Other examples of that function
- 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
Related Usage Examples