Prevent Revoking Timesheet If any Project is Approved

Normally users can revoke their timesheet submission, even if projects are approved as long as period is still open. This script prevents this behavior and if any of the projects are approved for the user, it prevents revoking timesheet submission. In this case only way to revoke a timesheet is contacting approver users and requesting them to reject timesheet.

This script requires WorklogPRO 4.7.1 at least.

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); if (timesheetApprovalRequest.action == "REVOKE") { def approvals = approvalService.getTimesheetApprovals(timesheetApprovalRequest.userKey, timesheetApprovalRequest.period.id); if (approvals.length > 0) { return "Since some of projects are already approved, you can't revoke your timesheet!" } }