5

I'm trying to send a variable from lwc to a screen flow. But when this variable is a Object or Array of Objects, the flow doesn't recognize and prints a empty value. I don't know what i'm doing wrong or if this is a bug.

Flow Running on API Version 59

My LWC code:

lwcFlowTest.js

import { LightningElement, api } from 'lwc';

export default class LwcFlowTest extends LightningElement {
    @api 
    get stringVariable() {
        return 'Text';
    }

    @api 
    get stringArrayVariable() {
        return ['Text', 'Array'];
    }

    @api 
    get objectVariable() {
        return {
            LastName: 'Lead',
            Company: 'Company Lead'
        }
    }

    @api 
    get objectArrayVariable() {
        return [
            {
                LastName: 'Lead',
                Company: 'Company Lead'
            },
            {
                LastName: 'Lead 2',
                Company: 'Company Lead 2'
            }
        ];
    }
}

lwcFlowTest.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>58.0</apiVersion>
    <isExposed>true</isExposed>

    <targets>
        <target>lightning__FlowScreen</target>
    </targets>

    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property
            name = "stringVariable"
            label= "String Variable"
            role = "outputOnly"
            type = "String"/>

            <property
            name = "stringArrayVariable"
            label= "String Array Variable"
            role = "outputOnly"
            type = "String[]"/>

            <property
            name = "objectVariable"
            label= "Object Variable"
            role = "outputOnly"
            type = "@salesforce/schema/Lead"/>

            <property
            name = "objectArrayVariable"
            label= "Object Array Variable"
            role = "outputOnly"
            type = "@salesforce/schema/Lead[]"/>
        </targetConfig>        
    </targetConfigs>
</LightningComponentBundle>

the html file its empty just with

And the flow its just 2 screens, in the first the lwc is called, and in the next its printed the values.

Complete Flow Flow Screen 1 Flow Screen 2

When I run the flow, this is the output from the flow Output From Flow

What i'm doing wrong? or pass object or object array from lwc to flow doesn't work?

2
  • Have you checked this? - salesforce.stackexchange.com/questions/360273/… - stackoverflow.com/questions/76234653/… Commented Jan 1, 2024 at 5:55
  • @TusharJadav yes, in my case i'm getting the output after I click next, I don't need this return on the same page. Because of that I don't think that is necessary to make a "FlowAttributeChangeEvent". My case is exactly the second option and don't work when a print the values. For the second link my variable is a getter, you can see on the screenshots this works nicely for String and String[], but not for SObject or SObject[] Commented Jan 1, 2024 at 16:12

1 Answer 1

2

The LWC code is working as expected.

To display Object you will need to indicate its properties like below

Lead Last Name: {!lwcFlowTest.ObjectVariable.LastName}
Lead Company Name: {!lwcFlowTest.ObjectVariable.Company}

To display Array variable you will need to use probably a Datatable as the the simple Display Text component does not have capability to show it

Check the output below where I used the same code as you

enter image description here

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.