I have a gallery (gallery1) that stores budget figures for different line items. Then I have another gallery (gallery2) where a user can select a line item from a list that is basically a lookup column from sharepoint based on the line items from gallery1.
When an amount is requested for approval, it goes to gallery2 where the approver selects the line item that corresponds to the description that comes with the amount requested. When the approver clicks "approve", the OnSelect of the icon is set to check the line item selected by the approver in gallery2, against the list of line items in gallery1, where the 2 items match, the amount requested is subtracted from the current balance of the selected line item.
I put the following in the OnSelect property of the gallery2 icon but it doesn't work as expected...
If(
(gallery1.Selected.LineItem = ThisItem.LineItem.Value) = true && !IsBlank(gal_NewBudget_3.Selected.CurrentBalance) && (gallery1.Selected.CurrentBalance - ThisItem.AmountRequested) > 0,
UpdateContext({varSub: gallery1.Selected.CurrentBalance - ThisItem.AmountRequested}),
Patch (
Vouchers, ThisItem,
{ExceededValue: "yes"}
)
);
However, this only compares the gallery2 line item with the first item in gallery1 and does not continue on to check the other items in the gallery. My expectation was for it to go through and compare all the items in gallery1 with the selected gallery2 item and perform the subtraction where the two line items match.
I've tried to use the ForAll function, but I don't exactly know how to go about it or if that's even what I should be using.
I would really appreciate any help/guidance on this. Thanks.
Gallery2

Gallery1
