7

I've got a custom built LWC to be used within a screen component in a flow. My component basically renders a collection of SObjects in a distinct way. It can also deal with different types of sObjects.

The only thing I cannot get working is my design time configuration file. I want to register the property to allow the user to bind any kind of sObject collection (Account, Contact, Custom Object, etc.) to that property in the Flow Builder.

This is my configuration:

<targetConfigs>
  <targetConfig targets="lightning__FlowScreen">
    <property name="records" label="Record collection" type="@salesforce/schema/Account[]" role="inputOnly"/>
  </targetConfig>
</targetConfigs>

This works - but limits the user to provide an Account collection.

I've tried all of the following - without success:

type="@salesforce/schema/SObject[]"

Result: Invalid reference SObject of type sobjectClass in file recordPicklist.js-meta.xml

type="@salesforce/schema/Object[]"

Result: Invalid reference Object of type sobjectClass in file recordPicklist.js-meta.xml

type="Object[]"

Result: Type 'Object[]' is either not supported by 'lightning__FlowScreen' or does not exist.

Can anybody tell me how to achieve this?

Thanks!

1

2 Answers 2

7

Generic SObject and SObject[] are not yet supported at the interface between LWC and Flow (TLDR: You can't get there from here). We're working on it right now, though, and hope to get it into Summer '20. You can get an early taste for some of the experience by looking at how we implemented it for Apex Invocable Actions in Spring '20

We don't have any short-term plans to support Object and Object[] in Flow, but if you have a use case where you want to work with very freeform data structures, take a look at the support for Apex-Defined Types. Basically, if you design classes in Apex that match your data structure, you can then pass instances of that type across Flow, LWC, and Invocable Action boundaries. A good intro to that is here.

2
  • 1
    Hi Alex, thanks a lot for the clarification. Looking forward for the sObject collections! Trying it with object[] was just an act of desparation. Again thanks for the links and info!
    – Christoph
    Jan 23, 2020 at 6:51
  • @Alex You may want to update the answer to convey to the community that this is possible now. Nov 15, 2021 at 1:56
7

I thought I would come back to this question because this is now possible I believe using propertyType.

<targetConfig targets="lightning__FlowScreen">
    <propertyType name="T" extends="SObject" label="Input Type" description="Generic sObject data type used for input sObject properties" />
    <property label="Record" name="records" role="inputOnly" type="{T[]}" />
 </targetConfig>

Please note the annotation for the collection type="{T[]}"

In your flow, you simply add enter image description here

Refer to official documentation for more information

You must log in to answer this question.

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