function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eric Latreille 8Eric Latreille 8 

LWC - @api recordId not working

I am not able to save my record. no error message is showing.
Here is my class.

public with sharing class ScheduleClass {
    public static Product_Schedule__c submitSchedule(String psRecordId, string psName, string psDescription){
        Product_Schedule__c psObj = new Product_Schedule__c();
        insert psObj;
        return psObj;
If I add the id of my record page it works but if I am trying to pass the id through my js file it is not working.
Here is my JS File:
import {LightningElement, track, api } from 'lwc';
import submitSchedule from '@salesforce/apex/ScheduleClass.submitSchedule';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';

export default class ScheduleClass extends LightningElement {
    @track psObjName;
    @track psObjDescription;
    @api psRecordId;
    @track errorMsg;
        if( == 'psName'){
        this.psObjName =;
        if( == 'psDescription'){
        this.psObjDescription =;  
        this.psRecordId = result.Id;
        window.console.log('psRecordId ' + this.psRecordId);       
        const toastEvent = new ShowToastEvent({
            message:'Record created successfully',
          /*Start Navigation*/
            type: 'standard__recordPage',
            attributes: {
                psRecordId: this.psRecordId,
                objectApiName: 'Invoice_Schedule__c',
                actionName: 'view'
         /*End Navigation*/
    .catch(error =>{

What Am I doing wrong?
Eric Latreille 8Eric Latreille 8
I did replace psRecordId with recordId this was an error on my side but still not working.
SwethaSwetha (Salesforce Developers) 
HI Eric,
Do you see any information in the logs?
Nikolay MitjulNikolay Mitjul
Greetings people,

I also have issue with @api recordId;
I can see it in Salesforce Lightning, but do not see it in Experience site (community).
In Experience builder, property set to {!recordId}
Profile is Admin with all accesses.
Console log shows - "Undefined"
I did try to add this LWC on to different objects details page - Undefined.

I`m out of ideas.
If anyone has something to share, please share :)
Thank you in advance.

here are my simple code samples:

    <lightning-card title="Foto upload" icon-name="custom:custom19">
        Here you should see the Record Id {recordId}

import { LightningElement, api, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class FileUploadLWC extends LightningElement {
    @api recordId;
    handleConsoleLogClick(event) {

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="" fqn="recordComponent">
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" label="Record ID"
                description="Should be set to {!recordId}"/>

Nikolay MitjulNikolay Mitjul
Forgot to mention that simple Aura component in same EXP Site works perfectly.

Aura component
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="recordId" type="String" />
Loran SagguLoran Saggu
Take a look at the documentation here ( - the recordId is not automatically bound in the Experience Site context. You need to bind the recordId in the xml file (see how the default value is set below):
    <targetConfig targets="lightningCommunity__Default">
            label="Record Id"
            description="Automatically bind the page's record id to the component variable"
            default="{!recordId}" />