Build a Flow Screen Component for Multiple Objects
You can build a single flow screen component that works with any sObject, instead of building one component per object. For example, you can build one data table component and reuse it in flows that operate on accounts, contacts, cases, or any other object. With Flow Builder, admins can pick the object type when they add the component to a screen.
To enable multiple objects on a component, declare a generic type in the component’s configuration file using the propertyType subtag. Properties that reference the generic type then accept the concrete object type the admin selects at flow design time.
In the component’s .js-meta.xml file, add a propertyType subtag inside the targetConfig for lightning__FlowScreen. The propertyType tag declares the named type that property tags can reference.
| Attribute | Required | Description |
|---|---|---|
name | Yes | The identifier for the generic type. Use this name, wrapped in curly braces, as the type value of any property that should use the generic type. |
extends | Yes | The base type the generic type extends. Must be SObject. Generic Object is not supported. |
label | No | The label for the type in the Flow Builder Object Type field. Defaults to the name value if omitted. |
description | No | The description shown in the Flow Builder Object Type field for this type. Use it to help admins understand what kind of object to select. |
In the same targetConfig, reference the generic type by name in curly braces as the type value of any property subtag. Use {T} for a single sObject and {T[]} for a collection.
In the component’s JavaScript file, declare matching @api properties.
If you declare multiple properties that all use the same propertyType, the admin maps the type once and all properties share the same concrete object. For example, a component that accepts both an input record and produces an output record can use the same type for both.
Because both properties reference the same propertyType, the admin selects the object only once. All properties that reference {T} remain in sync. This is an advantage over using Apex generic sObjects in flows, where each parameter must be mapped to a concrete object independently.
- Open your screen flow in Flow Builder.
- On a screen element, add the generic-type component.
- In the component’s property panel, locate the Object Type control. Select the sObject that this instance of the component should work with.
- After you select the object, the component’s properties that reference the generic type update to accept values of the selected type. Map each property to the appropriate flow variable.
For most use cases, Flow Builder’s built-in Object Type control is sufficient. For a more customized type-mapping experience, build a custom property editor and register it using the configurationEditor attribute on the targetConfig tag. For example, you can restrict which objects the admin can select, or show additional context alongside the picker.
For a complete example, see Generic SObject Input for Screen Components.
See Also