2

What is the best way to add dynamic values as datasource to FlowScreen components? Is there a way? Assuming that it's not supported, what would be the best alternative to keep the code consistent.

I need to offer a limited number of options when adding an LWC component to Flows or Record pages in order to configure it properly. Dynamic picklist do address that requirement and it does work well for lightning__RecordPage, however it did not work when I added to lightning__FlowScreen. The code push works fine, but it didn't render, so field and options are not available.

The LightningComponentBundle datasource property is defined as follows.

    <?xml version="1.0" encoding="UTF-8"?>
    <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
        <targets>
            <target>lightning__FlowScreen</target>
            <target>lightning__RecordPage</target>
        </targets>
        <targetConfigs>
            <targetConfig targets="lightning__RecordPage">
                <property type="String" name="stage" label="Stage" datasource="apex://StagePicklist" description="Select the stage that should be used to load the correct template."/>
            </targetConfig>
            <targetConfig targets="lightning__FlowScreen">
                <property role="inputOnly" type="String" name="recordId" label="Record Id" description="Record Id of the main entity" />
                <property role="inputOnly" type="String" name="stage" label="Stage" datasource="apex://StagePicklist" description="Select the stage that should be used to load the correct template."/>
            </targetConfig>
        </targetConfigs>
        <apiVersion>51.0</apiVersion>
        <isExposed>true</isExposed>
        <masterLabel></masterLabel>
    </LightningComponentBundle>
    

Note: As a workaround I'm planning to create a String input field which accepts any value and then apply extra validations.

4

1 Answer 1

1

We need to create a new object and embed it as part of the target config. Same example:

<targetConfig targets="lightning__FlowScreen" configurationEditor="c-stage-editor">
    <property role="inputOnly" type="String" name="recordId" label="Record Id" description="Record Id of the main entity" />
    <property role="inputOnly" type="String" name="stage" label="Stage" description="Select the stage that should be used to load the correct template."/>
</targetConfig>
    

A custom property editor uses JavaScript functions to communicate with Flow Builder, so it's possible to exchange values between flows and your component.

As pointed by @MartinLezer, there are a good documentation about it:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .