Create Flow Screen Components That Work for Multiple Objects (Generally Available)

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.

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 --> 
    <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."/>


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 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.

Changes Since Beta: Packaging and changes sets are now supported for flows that include a multi-object flow screen component.