So the section of code that is about to follow is on the OnSelect of an Icon in a gallery.
The first section patches a record in a list if varGalEdit is true. That same variable helps control visibility of a bunch of things based on current user etc.
This works correctly as does the reset of varGalEdit immediately below.
The next IF statement is trying to determine if 'SPIFF - Approvals' has records that match the number of approvers with the same approve_level. It would honestly be better if that IF statement didn't just compare counts but actually verified that there was a specific record in 'SPIFF - Approvals' for each 'SPIFF - Approvers'.Approver where the Approve_Level matched the Approve_Level from galItems but for now I'm satisfied using CountRows since the UI and input controls ensures the right results even though it's really not right.
I have a problem there I can't figure out to start with. Approver.Email = Approver is wrong. This specific statement:
Filter(
'SPIFF - Approvals',
Approver.Email = Approver
&& PositionID = galItems.Selected.ID
)
I think the UpdateContext statements are correct but until I can get the upper part working, they aren't even processing.
Then after all of this happens, I want to Patch the 'SPIFF - Requests' record which is galItems.Selected and set the Approve_Level based on the results from the CountRows comparison.
If(
varGalEdit = true,
Patch(
'SPIFF - Approvals', // The target data source
LookUp(
'SPIFF - Approvals',
ID = galApprovals.Selected.ID
), // Identify the specific record
{
Comments: txtApproverComment.Text,
// Update or set the value of Comments column
// Add more columns and values as needed
Status: rdoApproveEdit.Selected
// Update or set the value of Status column
// Add more columns and values as needed
}
),
Set(
varGalEdit,
false
),
If(
CountRows(
Filter(
'SPIFF - Approvers',
Approve_Level = galApprovals.Selected.Approval_Level
)
) = CountRows(
Filter(
'SPIFF - Approvers',
Approve_Level = galApprovals.Selected.Approval_Level &&
!IsEmpty(
Filter(
'SPIFF - Approvals',
Approver.Email = Approver
&& PositionID = galItems.Selected.ID
)
)
)
),
UpdateContext(
{
varNewApprovalLevel: galItems.Selected.Approval_Level + 1
}
),
UpdateContext(
{
varNewApprovalLevel: galItems.Selected.Approval_Level
}
)
),
Patch(
galItems, // The target data source (e.g., SharePoint list)
galItems.Selected, // Identify the specific record
{
Approve_Level: varNewApprovalLevel
// Update or set the value of Approval_Level column
// Add more columns and values as needed
}
)
)
Thanks in advance to whomever takes the time to read this.