I have a LWC that is embedded inside a screen flow. The component shows a datatable with records of Order object and I want to keep the records that the user has selected (with a checkbox) in the table in a wrapper in order to pass that information back to the screen flow and later to a subflow. I have created the wrapper, an Apex-defined variable in the flow and as I can see in the debug the variable only stores 1 record.
JS function
getSelectedOrderWrappers() {
return this.orderSelectedRows.map(selectedRow => {
const order = this.ordersEdited.find(o => o.Id === selectedRow.Id);
if (!order) return null;
return {
OrderNumber: order.OrderNumber,
Product_Business_Unit: order.Product_Business_Unit__c,
Product_Name: order.Product_Name__c,
PublisherIO_ID: order.PublisherIO_ID__c,
EffectiveDate: order.EffectiveDate,
EndDate: order.EndDate,
Order_Planned_Qty: order.Order_Planned_Qty__c,
Order_Planned_Purchased_Qty: order.Order_Planned_Purchased_Qty__c,
Total_Net_Budget_Planned: order.Total_Net_Budget_Planned__c,
Total_Net_Budget_Delivered_Billing: order.Total_Net_Budget_Delivered_Billing__c,
Top_Up_Sales_Qty: order.Top_Up_Sales_Qty__c
};
}).filter(Boolean);
}
Selected rows handler
handleOrderRowSelection(event) {
const selectedRows = event.detail.selectedRows;
this.orderSelectedRows = [...selectedRows];
}
Wrapper
global with sharing class TopUpLineGroupsWrapper {
@AuraEnabled public String OrderNumber;
@AuraEnabled public String Product_Business_Unit;
@AuraEnabled public String Product_Name;
@AuraEnabled public String PublisherIO_ID;
@AuraEnabled public Date EffectiveDate;
@AuraEnabled public Date EndDate;
@AuraEnabled public Decimal Order_Planned_Qty;
@AuraEnabled public Decimal Order_Planned_Purchased_Qty;
@AuraEnabled public Decimal Total_Net_Budget_Planned;
@AuraEnabled public Decimal Total_Net_Budget_Delivered_Billing;
@AuraEnabled public Decimal Top_Up_Sales_Qty;
global TopUpLineGroupsWrapper() {
}
}


@AuraEnabled List<TopUpLineGroupsWrapper> myListOfWrappers(example), to hold the values in a list.