I have a source list where each record has certain columns, such as City and State, with predefined dropdown values. Once can update multiple rows at the same time, and ID is the unique identifier for each record. I have created a checkbox and am trying to perform a bulk update using a button.
These updates are then created in a target list. First, it needs to check if there is an existing record for that source ID in the Title Column. If yes, it updates the existing record; if not, it creates a new record. The ID is the unique identifier in the target list. The logic works as expected for a single update. However, when performing a bulk operation (e.g., selecting three rows from the app), it creates 3 new rows in the target for the source record maximum ID(all 3 rows are not available in the target), and the other two rows are completely ignored.
Source List
ID | Customer ID | City | State |
12 | ABC123 | Buffalo | NY |
13 | XYZ456 | Orlando | FL |
ID | Title | Customer ID | City | State |
01 | 13 | XYZ456 | Orlando | FL |
02 | 14 | XYZ456 | Orlando | FL |
ForAll(
SelectedRecords,
Notify("Processing record with Source ID: " & Text(ThisRecord.ID), NotificationType.Information);
// Check if a record with the Title (mapped from Source ID) exists
If(
!IsBlank(LookUp(Target_List, Title = Text(ThisRecord.ID))), // Check existence
// Update existing record if found
Notify("Updating existing record with Source ID: " & Text(ThisRecord.ID), NotificationType.Information);
Patch(
Target_List,
LookUp(Target_List, Title = Text(ThisRecord.ID)), // Find the existing record by Title
{
'Updated State': UpdatedState.Selected,
'Updated City': UpdatedCity.Selected,
'CUSTOMER ID': CustID.Text
}
),
// Create a new record if not found
Notify("Creating new record with Source ID: " & Text(ThisRecord.ID), NotificationType.Information);
Patch(
Target_List,
Defaults(Target_List), // Create a new record
{
Title: Text(ThisRecord.ID), // Map Source ID to Target Title
'Updated State': UpdatedState.Selected,
'Updated City': UpdatedCity.Selected,
'CUSTOMER ID': CustID.Text
}
)
);
// Notify the end of processing for each record
Notify("Finished processing record with Source ID: " & Text(ThisRecord.ID), NotificationType.Success, 3000);
);
Notify(
"Processing record,
NotificationType.Information
);
ForAll(
Filter(
GalleryName.AllItems,
YourCheckBox.Value
) As _Data,
With(
{
_ID:
LookUp(
Target_List,
Title = Text(_Data.ID)
).ID
},
Patch(
Target_List,
{
ID:_ID,
'Updated State': _Data.UpdatedState.Selected,
'Updated City': _Data.UpdatedCity.Selected,
'CUSTOMER ID': _Data.CustID.Text
}
)
)
);
Notify(
"Finished processing record,
NotificationType.Success,
3000
);
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional