Ensure Time has been logged on Transition to Closed

Oliver Skelton October 11, 2024

Hi,

I have been tearing my hair out all day (what's left of it)

I am trying to add a validator to a transition that 

  • checks has any time be logged on the issue
  • asks the user to log time if not

Crucially, the transition should be valid if a single hour has been logged.

I have been trying to use Time Spent and 'Is not provided' but the transition screen insists on me adding time even if i have no more to add.

Seems like Time Spent is not the field to use but have played with Time Tracking too and still forces me to log more time on transition.

I have read various posts on here, added JMWE but as a bit of a simpleton that is not helping me because i don't write code :-(

10 Kudos points to the superstar who solves this for me!!

Thanks,

Oliver.

4 answers

1 accepted

1 vote
Answer accepted
Oliver Skelton October 12, 2024

So the work around seems to work. I created a custom field 'Work Logged' and set an automation to set it to yes once any work had been logged and then used this flag being set as the validator.

Sems crazy that a simple validation cannot solve this issue on its own (not that i have discovered anyway) 

 

Thanks.

Oliver Skelton October 15, 2024

Update, thanks to @Maciej Dudziak _Forgappify_ i am now using the expression issue.timeSpent != null && issue.timeSpent >= 60*60 which is checking if at least one hour is being logged and it works like a charm!

Maciej Dudziak _Forgappify_
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 15, 2024

Great to hear that!

I’m glad I could help :)

Cheers

Like Oliver Skelton likes this
3 votes
Maciej Dudziak _Forgappify_
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 14, 2024

Hi @Oliver Skelton 

If you want to check if at least 1 hour has been logged in the issue, then use the following Jira expression:

issue.timeSpent != null && issue.timeSpent >= 60*60

There are several apps providing Jira expression-based validator available on the Atlassian marketplace.

I am from Forgappify, and we developed Jira Expression Validator, which is part of the Workflow Building Blocks for Jira app. 

I would appreciate it if you could give it a try.

Cheers

 

Maciej Dudziak _Forgappify_
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 14, 2024

That will ensure that time is logged before the transition can be completed. On the other hand, if you want to ensure that time is logged during the transition (if you have a dedicated screen and added the Log Work field), you can check against originalIssue—which is a snapshot of the issue before the transition screen was opened:

originalIssue.timeSpent == null 
? issue.timeSpent != null
: issue.timeSpent > originalIssue.timeSpent
Oliver Skelton October 15, 2024

Thanks @Maciej Dudziak _Forgappify_ i am looking to solve the first problem, likelihood is time will have already been logged during execution, i just want to ensure it is by validating the time spent field on transition.

I will try out an let you know.

 

Oliver Skelton October 15, 2024

So it works!

I had been trying with issue.timeSpent != null for days in various different forms, but for some reason the expression on its own is not providing validation...

Thanks so much for your help and i will be sure to check out the apps.

 

3 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 11, 2024

Hello @Oliver Skelton 

What type of project are you using? Get that information from the Type column on the View All Projects page under the Projects menu.

If you are working with a Company Managed project you can add the native Field Required Validator and check the Summation Time Spent.

Screenshot 2024-10-11 at 8.28.38 AM.png

 

That will not provide a pop-up for the user to log time if none has been logged. It will simply show an error message pop up about the field being required and the Optional Error Message (if you provide one), and not complete the status transition.

There is not a comparable native workflow rule available in Team Managed projects.

 

Oliver Skelton October 12, 2024

Thanks @Trudy Claspill it is a company managed project, but still the Sum Time Spent isn't working. It recognises if no work has been logged but always insists on more work being logged on the transition itself.

 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 12, 2024

It worked in my testing. If time had been logged directly on the issue then the transition would complete.

Were you trying to to transition an issue where time was logged on subtasks rather than on the issue itself?

Had you deleted the validator that was checking Time Spent so that the only validator was for Sum Time Spent?

Oliver Skelton October 14, 2024

yeah, maybe i am missing something (or adding something!) but i was only working with Sum Time Spent. It is logical your solution works, but every time i move to close it asks for work to be logged irrespective of whether work has been logged.

On this i should have mentioned is that I am trying this at sub task level which could make a difference?

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 14, 2024

Hello @Oliver Skelton 

I did a test with a sub-task also, and it worked.

Can you show us the Workflow Scheme associated with the project? What I'm interested in is which Workflow is assigned to your sub-task issue type.

Then I'd like to see the Workflow itself. Is there more than one transition path to the destination status you have chosen?

When you say it asks for work to be logged, do you mean it presents a screen for logging work and/or it gives you a message that a field is required?

Oliver Skelton October 15, 2024

Of course, here is the workflow, transition is from final estimation to closed.

The screen shows 

1. The workflow - the transition is from 'Final Estimation' to closed.

Screenshot 2024-10-15 090218.png

2. The transition configuration 

  • Screen below on transition with all the fields that are mandatory for transition, several custom along with log work & time-tracking
  • 5 validated fields are the five custom fields relating to effort
  • Work logged flag is my workaround (removed it but still no joy).
  • finally Sum Time Spent isn't empty.

Screenshot 2024-10-15 090158.png

3. Screen configuration

Screenshot 2024-10-15 092220.png

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 15, 2024

I added a transition screen to my workflow and put the Time Tracking field on it. I still have the Validator to require the Sum Time Spent field.

With no time logged against the issue I try to transition it. The Screen with the Time Tracking fields displays. I do not enter any time, and I try to complete the transition. I get an error that Sum Time Spent is a required field.

Exit out of the transition and log time agains the issue. Then try the transition again. The transition screen displays, but I enter no time there. I am able to complete the transition because the Sum Time Spent was updated by my earlier Log Work activity, before I attempted to transition the issue.

 

On another issue with no time previously logged, I try the transition. The transition screen displays and I enter time spent. I try to complete the transition. I get the error that Sum Time Spent is a required field.

This is expected.  The Sum Time Spent field is not updated until the Log Work activity completes. The Log Work activity done through a transition screen is not completed until the transition Post Functions run. The Validator executes before the Post Functions. Subsequently the sum of Time Spent is still zero at the time the Validator executes.

To use the Sum Time Spent validator the issue must have time logged prior to starting to transition the issue. You can't use the Sum Time Spent validation to force and accept a time log entry that is part of the same transition.

2 votes
Aaron Pavez _ServiceRocket_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 11, 2024

Hi @Oliver Skelton 

> Checks has any time be logged on the issue 

It seems you can't do this with a validator. The built-in validator won't check if there is a value in that field. for that you need automation

The automation should check if the field is empty or if the value hasn't changed.

> asks the user to log time if not

You can do that in the transition. Check this guide

https://confluence.atlassian.com/jirakb/make-it-mandatory-to-enter-the-time-spent-during-transition-1318891775.html

JMWE: its not that difficult and you don't need to code. But for doing both with JMWE, you will need to use the inbuilt script creator or Jira expression.

With the field required validator you request to add values to the field and then a conditional (with Jira expression) to check if the field is empty or not.

example (you can test the expression) here the time tracking was empty. so the test was FALSE. then I added 1h, tested it again and now is TRUE.

2024-10-11 12_19_06-Update Workflow Transition 'Field Required Validator (JMWE app)' Validator - Jir.jpg

2024-10-11 12_18_48-Transition_ Resolve Issue - Jira — Mozilla Firefox.jpg

The issue you are mentioning could be due to this:

https://community.atlassian.com/t5/Jira-questions/Time-tracking-validator-not-working/qaq-p/1310848

Hope that helps a bit.

Regards

Aaron

 

 

Oliver Skelton October 12, 2024

Thanks @Aaron Pavez _ServiceRocket_ it has helped with my understanding but the key thing I want to achieve is to ensure nothing get's closed without the time being logged.

I am thinking i could add an automation to add a flag when time is logged and use that flag on transition. This seems like a sledgehammer to break a peanut situation but have invested to much time in this to give up now :-) thanks again, i will report back if i get it working.

 

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events