Don't Allow Logging Work Under Specific Conditions
You can control project’s permission schema to control who can log work on an issue or use workflow status properties to control on which statuses work can be logged on an issue but sometimes you may need more complex controls. Following scripts are just examples of such conditions all of which are required by some of our customers.
Don't Allow Logging Work If Remaining Estimate is Zero or Not Specified
Following scripts do not allow any worklog if remaining estimate of an issue is zero or not specified. This script works on 'Before Worklog Create/Update' script type.
def issue = worklog.getIssue();
def remainingEstimate=issue.getEstimate();
if (remainingEstimate== null || remainingEstimate == 0 ) { //no remaining estimate on issue, don't allow logging work
return "Can't log work because the remaining estimate is '0' or 'Not Specified'";
}
Don't Allow Logging Work If Original Estimate is Zero or Not Specified
This script prevents the worklog entry to an issue belonging to the ATP project in case the value of the original estimate field is null or zero.
import com.deniz.jira.worklog.*;
def issue = worklog.getIssue();
def project = issue.getProject().key;
def originalEstimate = issue.getOriginalEstimate();
def originalEstimateCheck = !originalEstimate || originalEstimate == 0;
if(project == "ATP" && originalEstimateCheck){
return "Can not log work!";
}
Don't Allow Logging Work Higher Than Remaining Estimate
Following scripts do not allow any worklog to be higher than remaining estimate of an issue. If there is no remaining estimate, users can log any duration.
def issue = worklog.getIssue();
if (issue.getEstimate() == null) { //no estimate on issue, allow logging work
return;
}
if (issue.getEstimate() < worklog.getTimeSpent()) {
return "Maximum duration you can log is " + issue.getEstimate() / 60 + " minute(s)"
}
Don't allow logging work on issues which has subtasks
This script does not allow logging work on issues which has subtasks. This is applied in use cases where a parent task is divided to subtasks and each subtask is separately estimated.
Don't allow logging work on subtasks
Simply the reverse of above script.
Don't allow logging work on specific issue types
Following script does not allow logging work if issue type is “Task”.
Don't allow logging work on resolved issues
Don't allow logging work when an issue is in a specific status
Don't allow logging work less than 30m
Logged Time should be in block of 15 minutes
Billable Time can't Be Larger than Time Spent
If Users are in specific user group only allows logging work on subset of projects
If Users are in specific user group only allows logging work on subset of projects
Don't Allow Specifying a Work Start Date After Due Date of the Issue
Don't Allow Worklog After a Specific Date Specified on Issue