Create Flow Screen Components That Work for Multiple Objects (Beta)
Where: This change applies to Lightning Web Components in Lightning Experience in Enterprise, Performance, Unlimited, and Developer editions.
- Define a type that extends the generic sObject data type by defining a <propertyType>.
- 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.
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.