How to use workflow validators to force time logging?

Leo McWilliams June 19, 2018

I am trying to create a rule so when someones moves a card from one column to the next on my kanban board, it forces them to log the time spend resolving the issue.

I already have the Time Tracking and Log Work fields showing on the issues. I have tried to add the following Validator onto my workflow but even when I log time on the card it doesn't let me progress the issue:

"Field Time Spent should be modified during the transition"

Can anyone tell me how I can achieve this?

12 answers

4 votes
Radek Dostál
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.
June 19, 2018

Hi Leo,

 

See here:

 # https://confluence.atlassian.com/jirakb/how-to-make-jira-applications-fields-required-in-a-workflow-transition-691011903.html

 

It should be "Time Spent" field set as required during transition.

i.e. Fields Required -> Time Spent

 

My understanding is that on Cloud you should have this validator included by default as per the article, on Server you'd need a plugin as far as I know, such as JIRA Suite Utilities (JSU).

(Although there are others that can do this as well, not just JSU.)

 

Regards,

Radek

Christie Diedrick August 14, 2019

Hi there, I use the Jira Cloud and I put the validator on my workflow to require Time Spent, but although people have logged time, that does not appear to get calc'd and it will not allow us to progress the Issue, as it shows the "Please Log Time" comment.

 

Has anybody found a workaround to this?

 

Thanks,

Christie

Like # people like this
fran.quintero March 31, 2020

Found a solution, via answer a ticket that I sent to Atlassian:

Once you have the validator "field required" or "field value changed" for Time Spent, since this validation happens during a transition, you need to register that change during, not before.

For that you can Edit the transition with that validator and add a screen with the Time Spent/Work log (is the same) field. I even created a new screen to show only that field once.

It seems counter-intuitive, because the same reasoning could be applied to any other field, but well, it worked for me.

Hope it helps!

Like # people like this
Orestis Michos July 9, 2020

That helped a lot! I was searching and googling for the way to do it nearly 3 days and that's the way to be done!!!

1 vote
Benjamin Compayre July 11, 2022

In case it's useful to anyone, I've finally found a way to achieve it the way I needed it.
I first tried with either ScriptRunner's Simple Script Validator or JMWE's Fields Required Validator but faced the issue Patrick has mentioned.

The only way to bypass this was to add a new screen with the Log Work field on the transition, but that wasn't working for me as we needed to restrict it to one project and didn't want to split our aligned workflow, but most importantly, it was enforcing the need to provide a new value for the field on transition even when a prior work was already logged for the issue.

So the solution was to rely on the Scripted (Groovy) Validator from JMWE with the following : 
!!issue.get("timespent") && issue.get("project")?.key == "ZYX"

Now I'm still able to transition without triggering the validator when there's already some work logged and I can restrict this to one or more projects. I prefer that solution to Scriptrunner's Custom script validator as it allows me to spare my brain with the method importing and stuff

Edit >> It didn't work eventually, somehow the project condition wasn't taken into consideration and my users also asked it to be restricted to some issuetypes and couldn't get it working. So I ended up changing one script made by my awesome groovy savvy colleague Mujibur Rahman to adapt it using the issue.get("timespent") as above. Can't share it here as it's not my IP, but it's a simple if else one. 

1 vote
Piotr Stefaniak [HeroCoders] May 17, 2021

Disclaimer: I work for the vendor providing the following solution.

If you are interested in validating whether the time was reported **before** the transition (but not necessarily **during** transition) and you can afford the cost of extra app, you might take a look at our Clockwork Pro. It comes with a custom workflow validator for ensuring some worklog has been reported before transiting an issue to next status.

1 vote
Orestis Michos March 4, 2021

Have you tried the solution given from fran_quintero? That worked for me. 

I will give you some screenshots of what I have done and everyone is forced to log time.

I added a screen named mandatory time tracking. image_2021-03-04_111234.png

Then I went to my workflow and added this screen to my transitions image_2021-03-04_111436.png

Also I added a validator on the transition that needs the Time Spent to be modified during the transition

image_2021-03-04_111835.png

 

That's all !!!

fran.quintero March 4, 2021

That's the idea!

The check from a validator triggers during transitions, so if you want to force a value in a custom field to be written (i.e. Time Spent), you can add a screen in that same transition, only showing those fields that you want to be filled, and the check will be effective.

@Orestis Michos is given a marvelous, step by step, with screenshots, here :)

0 votes
Sebastian Koch February 3, 2022

Exactly the same here.

0 votes
Amir Katz (Outseer)
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.
October 20, 2021

I ran into the same problem.

If you don't mind using an add-on (paid one), here is a solution.

We are using JMWE add-on and it includes this validator:

Field Required Validator (JMWE app)

It works correctly, when looking at the field 'Time spent'. 

BTW, the built-in Jira validator (the problematic one) displays this logged time field as 'sigma time spent', which confused me, as there is no such field defined in Jira.

Yet another example of Jira product managers not talking to each other. Sigh.

0 votes
Amir Katz (Outseer)
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.
October 20, 2021

JMWE = Jira Misc. Workflow Extensions. Very useful add-on.

0 votes
Patrick Chen March 3, 2021

Same problem. Workflow Validator is not recognizing that Time Spent has a value even though I verified it with a JQL "key = ABC-18845 AND timespent != null" returned my test issue ABC-18845 which has a several log work entries on it. However, the workflow transition keeps failing on the validator for Time Spent has a value. 

0 votes
Olivér Gájer March 31, 2020

Same here.

0 votes
fran.quintero March 20, 2020

And same here. No news in half a year?

0 votes
Tatyana Arenburg February 17, 2020

Same here. didn't find a workaround yet

0 votes
Blaine Shirk January 28, 2020

I'm facing the same thing as @Christie Diedrick . Any updates?

Suggest an answer

Log in or Sign up to answer