I have my own LWC component in my flow. The LWC component returns an array at the end with several entries of the type "Requested_Spare_Part__c". I have also configured the meta.xml as follows:
<?xml version="1.0" encoding="UTF-8"?><LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>59.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__FlowScreen</target> </targets> <targetConfigs> <targetConfig targets="lightning__FlowScreen"> <property name="outputVariable" type="@salesforce/schema/Requested_Spare_Part__c[]" role="outputOnly" label="Output Variable array" description="The output variable that will be used to pass data to the flow." /> </targetConfig> </targetConfigs></LightningComponentBundle>
So far everything compiles correctly, but the output in the flow does not meet the expectations. In the browser console, the output looks like this:
[ { "Spare_Part__c": "01t5p00000COqi9AAD", "Quantity__c": 1 }, { "Spare_Part__c": "01t5p00000COqnAAAT", "Quantity__c": 1 }]But in the flow like this:
Lightning Component: testcompScreen component: c:createRequestedSparePartInputs:Outputs:outputVariable = requestedSpareParts2BCreated ([[Requested_Spare_Part__c (Spare_Part__c:01t5p00000COqi9AAD, Quantity__c:1)], [Requested_Spare_Part__c (Spare_Part__c:01t5p00000COqnAAAT, Quantity__c:1)]])
So I cannot iterate over the list and enrich it with further data. Because the list outputs null when iterating. This does not correspond to the definition of the variable:
Data Type: Record
Object: Requested Spare Part
Allow multiple values (collection) = true
What am I doing wrong? Where is the error?
Hi @Matthias Kuich,
Your JavaScript class correctly constructs an array (outputVariable) of Requested_Spare_Part__c objects from data.
Can you try adding console logs in your LWC to check the values of this.data and outputVariable to make sure if the data is properly constructed and returned.
Thanks!