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
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.
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great to hear that!
I’m glad I could help :)
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
2. The transition configuration
3. Screen configuration
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> 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
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.