/
Prevent Revoking Timesheet If any Project is Approved
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!"
}
}
Related content
Worklog Scripts
Worklog Scripts
Read with this
Enforce a Preferred Approver for Each Project
Enforce a Preferred Approver for Each Project
Read with this
After Timesheet Approve/Reject
After Timesheet Approve/Reject
Read with this
Timesheet Approval Settings
Timesheet Approval Settings
Read with this
After Timesheet Submit/Revoke
After Timesheet Submit/Revoke
Read with this