My screen shows a single expense claim which is a gallery showing a set of expense items under that claim. Some items have been approved on a previous occasion and some were not, and were sent back for amendments. The entire claim cannot be approved until each item has been approved. So, I have to count previously approved items + NewlyToBeApproved items, and if the sum equals the number of items in the gallery, then the Approve Claim button shows up.
Each item has a checkbox. It has the following actions:
Checkbox1.OnCheck = Collect(ItemsToApprove, ThisItem)
Checkbox1.OnUnCheck= Remove(ItemsToApprove, ThisItem)
Checkbox1.Default= If(ThisItem.'Manager Approved'="Yes",true,false)
My screen's gallery Items are:
Filter('Expense Items', 'Expense Claim'=PendingApprovalGallery.Selected.'Expense Claim')
My screen performs a ClearCollect on screen visible using the same filter from the gallery plus 1 more filter criteria:
MyScreen.OnVisible = ClearCollect(ItemsToApprove, Filter('Expense Items', 'Expense Claim'=PendingApprovalGallery.Selected.'Expense Claim', 'Manager Approved'="Yes"))
This is so that the collection starts out on the right foot, and as the manager selects more items to approve those new items get added to the collection, and eventually the row count of the collection will match the row count of the gallery, and then the Approve Claim is available. If he selected items by mistake he can uncheck them to remove from collection, and he can Decline Claim which will run another action to update the Manager Approved field of only the items in the collection, while leaving the unselected ones unchanged (default is No).
The above works perfectly. But the problems starts below:
If the manager decides to UNapprove a previously approved item, things stop working. Checkbox1.OnUnCheck= Remove(ItemsToApprove, ThisItem) doesn't work to remove that item. This is because, somehow, the item that was ClearCollected into the collection on screen visible is NOT RECOGNISED AS THE SAME ITEM as the item I am unchecking/checking on.
Because it's not recognising that this item already exists in the collection, it doesn't remove it. Subsequently when I check the item, it adds it to the collection again, meaning I have duplicates.
Can someone help me with a workaround for this please?
Solved! Go to Solution.
I solved it!
Changes made:
Checkbox1.OnUnCheck = Remove(ItemsToApprove, LookUp(ItemsToApprove, 'Expense Item Unique ID'=ThisItem.'Expense Item Unique ID'))
Checkbox1.Default = ThisItem.'Expense Item Unique ID' in ItemsToApprove.'Expense Item Unique ID'
The default wasn't a necessary change but I thought it was a better option than the previous.
I solved it!
Changes made:
Checkbox1.OnUnCheck = Remove(ItemsToApprove, LookUp(ItemsToApprove, 'Expense Item Unique ID'=ThisItem.'Expense Item Unique ID'))
Checkbox1.Default = ThisItem.'Expense Item Unique ID' in ItemsToApprove.'Expense Item Unique ID'
The default wasn't a necessary change but I thought it was a better option than the previous.
****Update - just saw your post after I posted - you might try mine as well - it is a bit simpler. ***
Hi @LexiVeriCloud ,
This is a fairly complex process, so please bear with me if we do not get this right first go. From what I can see, you are trying to remove something from a list based on what is basically the same item in a collection/gallery, so try this
RemoveIf(
ItemsToApprove,
ID = ThisItem.ID
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
51 | |
47 | |
32 | |
32 |
User | Count |
---|---|
264 | |
91 | |
78 | |
68 | |
67 |