Time Off App - Denied Time off still subtracts from total
Opened this issue · 1 comments
Describe the bug
As an "approver" when you "Decline" someone's request, the totals are still being updated to reflect the denied request as if it were approved, subtracting from the "AllottedTimeOff" Total.
To Reproduce
- Have a user submit a request
- Have an approver deny the request
- See balances (note: For some reason, my Sharepoint lists are taking about 60 seconds to "update" through this process. It's probably a network issue, but keep an eye out for that on your end, apparently it's a known issue with SP lists?)
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
The code used to update the balances is as follows. It doesn't seem to differentiate between "Approved, Denied" in any way. I am not sure how to modify it to do such a thing.
Patch( TimeOffBalances, LookUp( TimeOffBalances, Employee.Email = selectedItem.'Created By'.Email && TimeOffType.Value = selectedItem.TimeOffType.Value ), { RequestedTimeOff: LookUp( TimeOffBalances, Employee.Email = selectedItem.'Created By'.Email && TimeOffType.Value = selectedItem.TimeOffType.Value ).RequestedTimeOff + selectedItem.Days } );
Seems as though I posted too soon - I kept messing around with it and appear to have figured something out that seems to be working. I added an "if" statement. I'm not sure if this is going to cause other issues that I haven't ran into yet, but updated code is below... and after some quick testing, it doens't seem to be updating the time off balance any longer if a request is rejected.
If(
approveOrReject = "Approved",
Patch(
TimeOffBalances,
LookUp(
TimeOffBalances,
Employee.Email = selectedItem.'Created By'.Email && TimeOffType.Value = selectedItem.TimeOffType.Value
),
{
RequestedTimeOff: LookUp(
TimeOffBalances,
Employee.Email = selectedItem.'Created By'.Email && TimeOffType.Value = selectedItem.TimeOffType.Value
).RequestedTimeOff + selectedItem.Days
}
)
,false)
;