Accessing All Worklogs of the Issue from the Script
If you require to access all worklogs of the issue from a script, you can do this by checking “Fetch all worklogs for issue” option. In this case, all of the existing worklogs of the issue will be passed to your script with “allWorklogs” array. Each entry in the array will be a worklog object as shown in the sample payload. This is an expensive operation and should not be used for simple scripts. Also allWorklogs can be an empty array and you have to handle this condition as a special case in your expression. Please see the following example which sums-up timespent values of the existing worklogs, add the current worklog’s time spent value and compare the result with issue’s original estimate field.
issue.fields.timeoriginalestimate >= (($count(allWorklogs) > 0 ? $sum(allWorklogs.timeSpentSeconds) : 0) + worklog.timeSpentSeconds)