Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagegroovy
import com.deniz.jira.worklog.approval.*;
import com.atlassian.jira.component.ComponentAccessor;

//We need to load WorklogPRO classes differently using getOSGiComponentInstanceOfType
TimesheetApprovalService approvalService = ComponentAccessor.getOSGiComponentInstanceOfType(TimesheetApprovalService.class);

def approvalRequests = approvalService.getTsApprovalRequestsForUserAndPeriod(timesheetApprovalAction.userKey, timesheetApprovalAction.period.id);
if (approvalRequests.length == 0) {
  return "User hasn't submitted his/her timesheet yet!";
}

Require Explanation When Rejecting a Timesheet

Code Block
languagegroovy
import com.deniz.jira.worklog.approval.*;
import com.atlassian.jira.component.ComponentAccessor;

def boolean emptyExplanation = timesheetApprovalAction.explanation == null || timesheetApprovalAction.explanation.trim().length() == 0;
if (timesheetApprovalAction.action.equals("REJECT") && emptyExplanation) {
  return "You need to specify a reason for timesheet rejection!"
}