Versions Compared

Key

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

You can execute execute a Groovy script just before usual handling of Jira timesheet approval/rejection and stop the process by returning an error message. Returned message will be shown to the Jira user that is trying to approvingapprove/rejecting reject a timesheet. If you don’t return anything from this script normal approval/rejection workflow will run.

...

Code Block
languagegroovy
if (timesheetApprovalAction.period.open) {
  return "Period is still open. You can't approve the timesheet when period is open."
}

Prevent Users to Approve/Reject Their Own Timesheet

Code Block
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.JiraAuthenticationContext;

def authenticationContext = ComponentAccessor.getJiraAuthenticationContext();
def loggedInUser = authenticationContext.getLoggedInUser();

if (timesheetApprovalAction.userKey == loggedInUser.key) {
  return "You can't approve your own timesheet!"
}

Prevent Approval/Rejection of Timesheet if User Hasn’t Submitted it Yet

...