When we create the weekly timesheet records individual time track records are created. Hence for restricting the approving of the Weekly time sheet we need to deploy scripts in the time track records and throw errors.
const beforeSubmit = (scriptContext) => {
let newRec = scriptContext.newRecord;
let status = newRec.getValue({
fieldId: ‘approvalstatus’
})
let employee = newRec.getValue({
fieldId: ’employee’
})
let currentUser = runtime.getCurrentUser()
if (checkForParameter(employee) && checkForParameter(currentUser.id)) {
let isSupervisor = checkEmployeeSupervisor(currentUser.id, employee)
if (!isSupervisor && status == ‘3’) {
throwError();
}
}
}