Hello everyone!
We are trying to track time and made the "Time tracking" field mandatory to close an issue. The thing is, even if you do enter the time data, when you try to close the issue it fails with with the error "Field Time Spent is required", how can this be? and how can we fix it?.
Thanks so much!
1. Create a screen (I call mine "Log Work Screen" The only fields I choose are Time Tracking and Log Work. (Comment will automatically be added). (No, you do not have to add this screen to your screen scheme.)
2. Edit your workflow:
On the outgoing Transition, click "Edit" and enter your "log work" screen name.
Publish your workflow.
When the user attempts to transition, the Log Work screen will pop out. In order to move forward, they will need to enter some time spent.
Is it possible to check for logged time prior or within the transition? We have the same problem, I can only get it to check for prior or check for logged time during transition.
The goal is to prevent an issue from being closed without logging any time, but we don't care if it was logged while in progress or logged when closed. Using Worklog Pro.
This validator prevents transition if no time is logged on transition, will not catch if time was logged prior.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException
def mIssue = issue as MutableIssue
def currentWorklog = mIssue.getModifiedFields().get("worklog")
if ( !currentWorklog ) {
throw new InvalidInputException("Time Spent must be logged when issues status updated")
}
This one prevents transition if there is no time logged prior, but when you try to log time on the transitions it will blocks you.
def timeSpent = issue.getTimeSpent()
timeSpent>=0 && timeSpent != null
Tried to combine the two didn't work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Solved in case anyone else has the same situtation
// check if work has been entered into the Time Spent field import com.opensymphony.workflow.InvalidInputException import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.MutableIssue def mIssue = issue as MutableIssue def timeSpent = mIssue.getTimeSpent() def currentWorklog = mIssue.getModifiedFields().get("worklog") if (!timeSpent && !currentWorklog) { invalidInputException = new InvalidInputException("Time must be logged in order to close.") }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ravya and @Trudy Claspill and thank you for your answers and your time.
We made a change in our approach and used a validator on the "Resolved to Closed" transition with the following:
!!issue.timeSpent
But now it won't even ask if the field is set or not. We've also tried this:
issue.timeSpent != null && issue.timeSpent != ''
Just to be absolutely sure, but maybe we are going the wrong way.
What we want actually is to make it mandatory to haver the time logged before closing an issue.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you trying to confirm that time has been logged against the issue at some point prior to the transition?
Or are you trying to confirm that more time is logged during the transition?
Or are you trying to establish a rule that requires time to be logged during the transition only when there has not been any time logged previously?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Trudy,
It is actually more simple, what we really need, is to forbid an issue from being closed if there is no time logged for it, doesn't matter when the time was logged, you just shouldnt be able to close it without some time logged.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Our Jira instance doesn't include any add-ons that allow us to incorporate code into Validators. We just have basic Validator functionality available so I'm not able to experiment with the solution you've tried.
The trick is to ensure your Validator is looking at data stored in the issue already, versus looking at changes being made to the issue during the transition. Time Spent is an unusual field in that there is the Time Spent field that you could be filling in when making the transition (adding more Time Spent to the issue) and there is also the accumulated Time Spent recorded for the issue. What you really need to check is the accumulated Time Spent. What might be happening is that it is trying to validate that more data is being entered for Time Spent during the transition.
Unfortunately I don't have the tools/apps necessary in my JIRA instance to figure out how to do what you want. At another employer I had access to Adapativist's ScriptRunner for JIRA, which might be a tool that could help. I recall that we could run Groovy scripts using that tool, and look at other information already recorded in the issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Trudy,
Thank you for your insight, I'll look into it, don't really know how to target the correct field if that was indeed the case, but I'll investigate about it.
Thanks again for your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure if there is an actual field that stores the total time spent, or if that is calculated in real time based on the individual Work Logs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this code works fine.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.opensymphony.workflow.InvalidInputException
def mIssue = issue as MutableIssue
def currentWorklog = mIssue.getModifiedFields().get("worklog")
if ( !currentWorklog ) {
throw new InvalidInputException("Time Spent must be logged when issues status updated")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Exactly what did you do to make the "Time Tracking" field mandatory?
Did you change the Field Configuration to make "Log Work" required instead of optional? Or are you using a Validator in the workflow transition for closing the issue to ensure the field is not empty?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Validator
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Facundo Colella ,
I guess the condition was set in such a way that even though the spent is filled, it should be changed during the transition.
So once recheck the comdition.
--Ravya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.