0

have a component like,

<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
   <apiVersion>52.0</apiVersion>
   <isExposed>true</isExposed>
   <targets>
       <target>lightning__RecordAction</target>
   </targets>
    <targetConfigs>
   <targetConfig targets="lightning__RecordAction">
     <actionType>ScreenAction</actionType>
   </targetConfig>
 </targetConfigs>
</LightningComponentBundle>

I need the record Id from which record page this action is fired, able to access it in <actionType> Action </actionType> but have to use recordId in <actionType> ScreenAction </actionType>

JS file is like,

import { LightningElement, api } from "lwc";
 
declare default class Simple extends LightningElement {
    @api recordId;

    connectedCallback() {
        console.log('===============');
        console.log(this.recordId);
        console.log('===============');
    }

    renderedCallback() {
        console.log('------------');
        console.log(this.recordId);
        console.log('------------');
    }
}
0
0

You can see this answer as well that also confirmed my testing.

Using recordId in your html template will show the value in the 2nd renderedCallback once the Id is provided. You can add a conditional to allow the template to only show once there's a value in recordId as you presumably are doing some logic related to the record the action is called from:

<template>
    <template if:true={recordId}>
        <!-- Do whatever you want to do -->
    </template>
</template>
1
  • Yes, it is available in the 2nd renderedCallback, will have to do other restructuring according to functionality. Jun 17 at 4:44

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.