3

I have a LWC component, that has a very simple public property:

@api recordId;

And I have a LWC config, that exposes this public property to the Flow Builder

<targets>
<target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
    <targetConfig targets="lightning__FlowScreen">
        <property name="recordId" type="String" label="Record Id" default="{!recordId}" required="true"></property>
    </targetConfig>
</targetConfigs>

In my flow, there is a standard variable recordId, and when I put my LWC in one of these screen actions, I can even select the "Record Id" and fill it with {!recordId}. But: recordId (in the LWC) never gets populated. It is populated in the Flow. At least it seems that way, if I output {!recordId} in a "display text"

Why?

2 Answers 2

1

I had a similar scenario where I wasn't able to the record Id passed into my component in a flow, but it worked on a record page. I tried using the result of a query {!getOpportunity.Id} rather than {!recordId} even though they would be identical and that worked. Perhaps the reason has something to do with this:

The recordId is set only when you place or invoke the component in an explicit record context. In all other cases, the recordId isn’t set, and your component shouldn’t depend on it.

From Developer.Salesforce.com: Make a Component Aware of Its Record Context

0

The issue for me was that default values did not work at all for design properties in the LWC Flow but it would work in a community.

I have an example here: Pass record ID to custom LWC Component and Modal Flow Screen

This wasn't only for recordId but when I would try to pass a hardcoded string Object as well as default for example 'MyObject__share'

This works:

    <isExposed>true</isExposed>
<targets>
    <target>lightning__RecordPage</target>
    <target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
    <targetConfig targets="lightning__FlowScreen">
        <property name="recordId" type="String" label="Record Id" description="Input Record Id as a string or use variable {!recordId}"/>
        <property name="shareObject" label="Share Object API Name" description="Type in Share Object API Name ex: MyObject__share" type="String"/>
    </targetConfig>
</targetConfigs>

This did not:

<isExposed>true</isExposed>
<targets>
    <target>lightning__RecordPage</target>
    <target>lightning__FlowScreen</target>
</targets>
<targetConfigs>
    <targetConfig targets="lightning__FlowScreen">
        <property name="recordId" type="String" label="Record Id" description="Input Record Id as a string or use variable {!recordId}"/>
        <property name="shareObject" label="Share Object API Name" description="Type in Share Object API Name ex: Serious_Incident__share" type="String" default="myObject__share"/>
    </targetConfig>
</targetConfigs>

You must log in to answer this question.

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