0

Recently Salesforce made embedding and launching a flow via LWC available. I have been unsuccessful at making this work even after looking through the documentation. https://developer.salesforce.com/docs/component-library/bundle/lightning-flow/documentation

It looks like you pass the flow name as well as the input variables which in this case would be a recordId. It specifically says that it takes an array in, so I added the recordId to the array and passed it in as a parameter.

html:

<template> <lightning-flow if:true={inputVariables} flow-api-name='virtual_diagnostic_notes' flow-input-variables={inputVariables} > </lightning-flow> </template> 

JS:

 @api recordId; connectedCallback(){ //do something console.log('RECORD ID FOR LWC', this.recordId); console.log('inputVariables', this.inputVariables); } get inputVariables() { return [this.recordId]; } 

I keep getting this error:

enter image description here Any thoughts?

1 Answer 1

1

A flow has variables that you set as available for input. Each variable has a name and a type.

When passing values for these variables you must simply pass a JavaScript array of object with properties that name the variable and provide the variable type and value.

Assuming you called your variable "recordId" in the flow and it is a string that receives an ID from your LWC, you need to do the following:

get inputVariables() { return [ { name: 'recordId', type: 'String', value: this.recordId } ]; } 
1
  • Thanks for answer. I thought we needed to pass an array, not an array of objects. Commented Nov 16, 2022 at 16:16

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.