Create Flow Screen Components That Work for Multiple Objects (Beta)

Now developers can create reusable screen components that use the generic sObject and sObject[] data types. They can build one component that works for multiple objects, rather than one component for each individual object. For example, they can build a data table component that works with any collection of records, from accounts and contacts to custom objects.

Where: This change applies to Lightning Web Components in Lightning Experience in Enterprise, Performance, Unlimited, and Developer editions.

Note

Note

As a beta feature, the support of the generic sObject data type in custom flow screen components is a preview and isn’t part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported, and Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for the support of the generic sObject data type in custom flow screen components in the Trailblazer Community.

How: Create a custom flow screen Lightning web component, or edit an existing one. In its configuration file, a flow screen component has the target lightning__FlowScreen.
  1. Define a type that extends the generic sObject data type by defining a <propertyType>.
  2. For each property that maps to the same object, set the property's type attribute to {propertyTypeName}. If the attribute expects a collection of that object, set the type attribute to {propertyTypeName[]}. For example, if propertyTypeName is T, use {T} or {T[]}.

    You can reference the same property type for single and collection properties. To set the type attribute for single or collection variable properties, see the comments in the code example.

<!-- myComponent.js-meta.xml --> 
<targetConfigs>
    <targetConfig targets="lightning__FlowScreen">

        <!-- Declare a property type that extends SObject for single and collection variable properties.-->
        <propertyType name="T" extends="SObject" label="Object" description="Select an object." />

          <!--To use a collection of the SObject data type, use the braces in this syntax, type="{T[]}".-->
          <property name="tableData" label="Records to Display" type="{T[]}" role="inputOnly" required="true" 
                    description="REQUIRED: Record Collection variable containing the records to display in the data table. Make sure to select a variable that matches the selected object."/>

          <property name="preSelectedRows" label="Preselected Rows" type="{T[]}" role="inputOnly" 
                    description="Which records should be selected by default when the table renders? Select a Record Collection variable that contains those records."/>

          <property name="outputSelectedRows" label="User-Selected Rows" type="{T[]}" role="outputOnly" 
                    description="Which records were selected by the user at runtime? This value should be stored in a record collection variable."/>

    </targetConfig>
</targetConfigs>

Previously, the example component was tied to one object, such as Account, Contact, or myCustomObject__c. But now developers create one component, and the Flow Builder admin chooses the object each time they use that component.

Data table flow screen component

For this beta feature, when a flow screen component defines a generic sObject data type, custom objects that the flow references aren’t included in the package automatically. To deploy the package successfully, manually add those referenced custom objects to the package.