In a Flow, I can retrieve an object and several fields. Is it possible to pass the object to a Lightning component used in a screen? I've tried setting up an attribute as Map or Object, and adding the attribute to the Design, but when I attempt to save the Lightning component, I get errors like this:

Error:(1, 1)

The flexipage:availableForAllPageTypes interface doesn't support these attribute types in the design resource: map.

The forceCommunity:availableForAllPageTypes interface doesn't support these attribute types in the design resource: map.

The lightning:availableForFlowScreens interface doesn't support these attribute types in the design resource: map.

The flexipage:availableForRecordHome interface doesn't support these attribute types in the design resource: map.


So the answer was contained within a comment in this post: Is it possible to return a value from a Lightning Component to a flow?

In my Flow, I setup a variable called orderRecords of type record, and checked the Allow multiple values (collection) property.

Next, I added a get records element to my flow. Itt retrieves all of the order records with the matching recordId (passed into the Flow via a variable with that name). There is only one, but it is stored in orderRecords collection variable.

Then in my Lightning component, I defined an attribute to receive the collection variable:

<aura:attribute name="orderRecords" type="package__Order__c[]" />

and included the following in the design part:

<design:attribute name="orderRecords" label="Order records" description="Only the first one in the collection is used" />

And in my component's init(), I get the first record in the collection and save that in an attribute:

var orderRecords = component.get("v.orderRecords");
var orderObj = null;

if(orderRecords.length > 0) {
    orderObj = orderRecords[0];
    component.set("v.orderObj", orderObj);

Then, I updated my flow to pass the orderRecords variable to to the component as an attribute.

Its a bit of work to do things this way, for sure, but does do what I need. It certainly will be nice whenever SF updates Flows to be able to pass a single record to a component.


As per documentation, you cannot use a generic Map or Object as an attribute for a flow. You can, however, use an Apex-defined datatype or an sObject type. If these doesn't satisfy your requirement, you can pass the object as a JSON string instead and parse it in the component.


  • So I would need a step in the Flow that would convert the retrieved object into a JSon string? How exactly would that be done? Via an Apex reference? Sep 3 '19 at 19:42
  • I used a text template variable with hardcoded param names to generate the JSON string and passed it as a param to the flow action. Ex: {"paramName": {!paramValue}} Sep 3 '19 at 23:17
  • I don't believe a Flow variable for a single record can be passed to a Lightning component included in a Flow screen. It does seem to work for a variable containing a record collection, though. Sep 26 '19 at 12:55

Flow's new Apex-defined Data Types allows you to define a rich object as an Apex Class and then pass it between Flow and LC's. See https://unofficialsf.com/part-1-manipulate-complex-internet-data-in-flow-without-code/ and https://unofficialsf.com/tdx-session-videobuilding-advanced-flows-with-choices-loops-and-new-apex-defined-types/

Easier than serializing and dealing with JSON, generally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.