web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If statement with ForA...
Power Apps
Unanswered

If statement with ForAll and multiple Patch - Check-in & Checkout Logs

(0) ShareShare
ReportReport
Posted on by 35

Hi everyone,

 

I need some assistance to see if my scenario can be obtained. I figure it can, but the solution has eluded me. I have an app that has a check-in log and a check-out log. Currently, I have two different sharepoint lists (One for each) that drive the app, but I want to find a way to have one sharepoint list with a Check-in column and Check-out column. Everything is driven by a unique identifier that will be scanned by a barcode scanner. The app is built and functioning great with the two sharepoint lists, but I am having issues with the "OnSelect" property of a button that needs to write to the sharepoint list in the combined scenario.

 

My sharepoint list (Checkin/Checkout Log) is as follows:

ScanCodeCheckinDate_TimeCheckoutDate_Time
2023-12342/23/2024 13:572/25/2024 08:14

2023-1456

2/24/2024 15:10 
2023-14782/24/2024 16:27 

 

I have other button that trigger a process to remove any scanned duplicates from the collections and you will then see I bring back the other columns that are not the unique identifier. The issue I am running into is the second part of the code below. I want the code to count the rows of the SharePoint list by filtering by the unique identifiers and if the CheckoutDate_Time is blank. If the total returned row count is greater than zero, then patch the checkoutDate_Time only, otherwise (count rows returns zero) write the scancode and the checkinDate_Time. 

I think I am missing a way when the count returns a total greater than zero, a way to write to that specific record, but I can't seem to wrap my head around that. Any help would be appreciated.

ClearCollect(
 colScansCleanCollection,
 AddColumns(
 RenameColumns(
 colScansdistincttest,
 "Value",
 "scancode_renamed"
 ),
 "scancode",
 LookUp(colScanstest, scancode_renamed = scancode).scancode,
 "scantime",
 LookUp(colScanstest, scancode_renamed = scancode).scantime
));
If(
 ForAll(
 colScansCleanCollection,
 Countrows(
 Filter(
 'Checkin/Checkout Log',
 ScanCode = scancode || IsBlank(CheckoutDate_Time)
 )) > 0),
 Patch(
 'Checkin/Checkout Log',
 Defaults('Checkin/Checkout Log'),
 {
 ScanCode: scancode,
 CheckoutDate_Time: scantime
 }
 ),
 Patch(
 'Checkin/Checkout Log',
 Defaults('Checkin/Checkout Log'),
 {
 ScanCode: scancode,
 CheckinDate_Time: scantime,
 Title: "Checkin/Checkout Log"
 }
 )
);
Clear(colScanstest);
Clear(colScansdistincttest);
Clear(colScansCleanCollection);
UpdateContext({ShowPopUp: false});

 

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard