Validating that Time have been logged before closing

Francis Gagnon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 11, 2017

I'm new to Jira and I'm trying to figure out how to make sure time have been logged at least 1 minute. So, if Time Spent = "0" OR NULL it should pop-up a message and prohibit to close the issue. I'm not a programmer :/

Jira Server 7.3.4 with Script Runner

 

1 answer

1 accepted

2 votes
Answer accepted
Aidan Derossett [Adaptavist]
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 25, 2017

Hey there Francis,

I think I can help you out with this!

Follow these steps:

  • So first what you're going to need to do is open the workflow of the project that you would like this validation to function on. 
  • Then hit the edit button and switch to a diagram view.
  • Now, click on the transition in which you would like this validation to take place (in your case I assume you want the transition just before your "Close" or "Done" status).
  • After clicking the transition, a pop-up box should appear to your right. In that box click the Validators link.
  • From there, click "Add Validator"
  • Select a Script Validator and hit "Add"
  • Then click Simple Scripted Validator
  • Once there, add a note such as "Require Time-Spent" or something like that suites your uses. Then put this short script into the Condition window:
def timeSpent = issue.getTimeSpent()

timeSpent>=60000 && timeSpent != null

          and the Error Message "Error: There has been no time spent           on this issue!" But leave the Field box blank.

  • Time-spent is stored in milliseconds, so if you are looking for at least 1 minute you'd need to ensure that time-spent is at least equal to 60000 milliseconds. That's the purpose of the last line in the code block.
  • From then you can finish creating the validator and publish your workflow. 

If I'm following your question correctly, this should do the trick.

Let me know how it goes!

Aidan

Tim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 12, 2024

Despite this being an ancient topic, it helped me solve this particular issue today, so thank you! :) 

One thing I'd like to point out (and one that might have changed since this was originally posted) is that timeSpent is stored in seconds, not milliseconds. So timeSpent >=60 suffices to have at least one minute of logged work.

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events