I have a Lightning record page and just want to include the recordId in my JSON string variables passed to Flow. I understand including the decorator, etc I just cannot seem to get the correct format for including the recordId in the JSON.parse(this.flowParams). Passing regular String variables are working fine.

I'm also not clear if using this pattern I still need to include the recordIdin the <targetConfig><property> section? I think no.

[{"name": "recordId", "type": "String", "value": "{!recordId}"}]
import { LightningElement, api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class cardNpiSingFlowCmp extends LightningElement {
  @api flowName;
  @api recordId;
  @api flowParams;
  @api vaEntryPoint;

    get inputVariables() {
          return JSON.parse(this.flowParams);
    handleStatusChange(event) {
        if (event.detail.status === 'FINISHED') {
            // set behavior after a finished flow interview

1 Answer 1


You can just spread it into a new object and add the recordId property.

return { ...JSON.parse(this.flowParams), recordId };
  • Somethings not quite right with the syntax at least because return {JSON.parse(this.flowParams), recordId}; is giving me compiler errors. Parsing error: Unexpected token, expected ","
    – ddeve
    Apr 15, 2023 at 2:18
  • 1
    That's not what I have in my post though. The ... is a very important piece of the syntax. See spread syntax.
    – Adrian Larson
    Apr 15, 2023 at 3:02
  • Missed that piece thought just ellipses. Still not working but now wondering if because I'm trying to pass the recordId to an autolaunched Flow? Doesn't seem like I should be having so much trouble with this part. When I include recordId as another property I'm either not using correct syntax to pass {!recordId}, which is not accepted in LEX page, or I don't see it if leaving assignment out as docs suggest its passed automatically if on LEX Record page which it is.
    – ddeve
    Apr 15, 2023 at 16:52

You must log in to answer this question.

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