how to force people log work before Resolve Issue?

fabby January 13, 2013

my jira version is 4.4.1.

i tried to use workflows' Validators (Field Required for Time Spent),but failed.

even i have log work,"Workflow Error" still says Time Spent is required when Resolve

anyone can help?

4 answers

1 accepted

0 votes
Answer accepted
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Use Script Runner plugin and add a validator to check whether the total spent time is more than zero.

This link may help with the code https://answers.atlassian.com/questions/101423/time-spent-in-in-progress-open-statuses-how-to

Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Sorry Fabby, it's very tough to understand what you really mean by that statement. If you don't mind can you please rephrase?

And why don't you check @mizan 's suggestion? I guess that is a better.

fabby January 13, 2013

hi,Renjith

code in this link try to get Time Spent in History Tab,but when delete some work logs, "change history" can't reflect actual Time Spent value

fabby January 13, 2013

sorry of my poor English.

i add below code to Script Validator of workflow using Script Runner Plugin

import com.atlassian.jira.issue.Issue
issue.getTimeSpent()

and it meets my requirement.


Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Ok good, I initially thought it was a question for us.

4 votes
P4T_Christoph July 17, 2014

Actually for anyone checking in this is better as it allows you to log work in the edit screen as opposed to fabbys solution which requires already logged work prior to triggering the transition:

import com.atlassian.jira.issue.Issue 
issue.getTimeSpent() || issue.getModifiedFields().get("worklog")
Nathan Nantais November 25, 2015

Thanks, this is perfect.

Carlos Fernandez April 14, 2016

Hello, this is working fine, but it's not when the ticket has sub-tasks with logged time. Any idea?

Will July 5, 2016

I have been using "issue.getModifiedFields().get("worklog")" in a script validator for a workflow transition to determine if a user has added 'time worked' in the transition.  This has been working fine for several months.  I have recently upgraded to ScriptRunner v4.1.3.14 and the ScriptRunner editor now gives me the following error on this code "Cannot find matching method com.atlassian.jira.issue.Issue#getModifiedFields()."  I find "getModifiedFields()" in the MutableIssue class, see https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/MutableIssue.html, and my understanding was that this came into the script in the binding for scripts in the workflow transitions.  Do I need to declare a new mutable issue from the issue passed in the script binding and then use "getModifiedFields()"?  I am wondering if anyone has a solution to this that works with the newer version of ScriptRunner?  Thank you for ant help.

Dayna Waytashek August 22, 2016

I am having the same issue as Will. Anyone have any ideas on what an be done to fix it?

Italo Qualisoni [e-Core]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2017

@Will and @Dayna,

We were with this same case and were able to resolve with following code:

import com.atlassian.jira.issue.Issue 
import com.atlassian.jira.issue.MutableIssue
def mIssue = issue as MutableIssue
return mIssue.getTimeSpent() || mIssue.getModifiedFields().get("worklog")

It worked for us against JIRA 7.1.9 :D

Like Zita Bagi likes this
Zita Bagi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2020

@Italo Qualisoni [e-Core] thank you for this!

2 votes
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013
0 votes
Troy Larson November 2, 2015

Check out www.timetrackingenforcer.com

Suggest an answer

Log in or Sign up to answer