0

I invoke a flow from an LWC component. I just want to pass an array of Contact to the flow from LWC (in the js below, the 3rd variable). What should be the type that we should use in the inputVariables for SObject arrays?

html

<template>
    <lightning-flow
        flow-api-name='Survey_customers',
        flow-input-variables={inputVariables}
    >
    </lightning-flow>
</template>

js

get inputVariables() {
    return [
        {
            name: 'OpportunityID',
            type: 'String',
            value: '<Opportunity.Id>'
        },
        {
            name: 'AccountID',
            type: 'String',
            value: '<Opportunity.AccountId>'
        },
        {
            name: 'ContactList',
            type: 'SObject[]',
            value: '<Contact[]>'
        },

    ];
}

When I use type: 'SObject[]', the following is the error:

The dataType SObject[] for argument ContactList is not a valid data type. 
2
  • 1
    Have you tried with just type: 'SObject'? Commented Nov 11, 2024 at 17:32
  • @PhilW Just tried it, that works!. Commented Nov 12, 2024 at 7:57

1 Answer 1

3

The documentation isn't particularly clear on the subject, simply stating:

You can map only these types and their associated collection types between flows and custom Lightning web components.

However, you set the type for the input variable to the singular version of the required type, even for collection variables.

Since you want to pass a collection of SObject records in this case, you need to simply specify:

        {
            name: 'ContactList',
            type: 'SObject',
            value: '<Contact[]>'
        },

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.