1

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() {

    }
}

enter image description here

enter image description here

7
  • In your "Edit Variable" screenshot where you are defining var_selectedOrders, have you tried checking the "Allow multiple values (collection)" checkbox? Commented Sep 8 at 12:57
  • If I set the variable as a collection I can't select it as the variable to store the results of Selected orders output. Commented Sep 8 at 13:08
  • How is the output variable defined in your LWC? Commented Sep 9 at 3:51
  • I have exposed a variable with @api and declared it as an apex defined property in the xml file Commented Sep 9 at 6:46
  • 1
    This is expected, your wrapper class holds only a single "record". Unless you have another @AuraEnabled List<TopUpLineGroupsWrapper> myListOfWrappers (example), to hold the values in a list. Commented Sep 9 at 14:46

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.