The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Log work during a transition

Bettina Hübner
Contributor
August 31, 2017

Hi,

my question relates to this one.

I want to validate for a transition that some work has been logged for the issue. It works (with JMWE Field is required validator) if the user has already logged work before the transition. If the user hasn't logged work before the transition and logs work in the transition screen, the validator seems not to be able to access this new work log and does not allow to execute the transition.

I also tried to create a simple scripted validator using Scriptrunner but the behaviour is the same (the new worklog entry is not yet available).

Any ideas how to solve this?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

5 votes
Answer accepted
Bettina Hübner
Contributor
August 31, 2017

In the meantime I did find a solution how to check a user logs work in the transition screen using a Simple scripted validator (Scriptrunner Validator):

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue

Map<String,ModifiedValue> modifiedValues = ((MutableIssue)issue).getModifiedFields();

return modifiedValues.containsKey("worklog")

And if you want to check some work has been logged for the issue (during the transiton or already before): 

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.onresolve.scriptrunner.runner.util.UserMessageUtil

Map<String,ModifiedValue> modifiedValues = ((MutableIssue)issue).getModifiedFields()

return modifiedValues.containsKey("worklog") || (issue.timeSpent > 0)

Jira 7.1.2

Sergio Betterelli _ACP-JA _ ACP-JSW_ __
Contributor
October 12, 2017

Great solution! :)

Christof Hurst
Contributor
March 10, 2022

Can be done simply in one line

issue.timeSpent || issue.modifiedFields.containsKey("worklog")

That's groovy style. No imports, no cast nevessary. Even no "return".

0 votes
shivamdu
January 16, 2019

Instead we could add "Time spent" as a mandatory field.

Christof Hurst
Contributor
March 10, 2022

Only if no other check is included. For me the timelog is only necessary for some issueTypes.