Code snippet to fetch the worklog time logged during a transition

Abstract

This code snippet fetches the time logged in the work log during a transition.

Logic

  • Access the fields modified during the transition
  • Fetch the new worklog, if any.
  • Fetch the Time spent entered in the new worklog

Snippet

return issue.getModifiedFields().get("worklog")?.newValue?.worklogResult()?.getWorklog()?.getTimeSpent()

Examples

The output of this code snippet is a Long representing the number of seconds which you could use in a Groovy expression, to set a field value with the worklog entered during a specific transition. For example: Set a custom field with the total work log entered during the rework on an issue.

References