I'm trying to get the sObject Name on community record page. Getting the recordId works! But getting the sObject name does not.. Can I get it automatically in community ?
followed this doc which says its possible : https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_object_context
Thats my Lightning Web component markup:
XML :
`<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>47.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>My LWC</masterLabel>
<description>Community Component</description>
<targets>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
<targetConfigs>
<targetConfig targets="lightningCommunity__Default">
<property name="recordId" type="String" label="Record ID" default="{!recordId}" description="The value should be {!recordId}."/>
<property name="objectApiName" type="String" label="Object Name" description="Bind the page's {!objectApiName} to the component variable" default="{!objectApiName}" />
</targetConfig>
</targetConfigs>
</LightningComponentBundle>`
JS
import { LightningElement, api} from 'lwc';
export default class MyComp extends LightningElement {
@api recordId;
@api objectApiName;
connectedCallback() {
console.log('recordId ' + this.recordId); // this works
console.log('objectApiName ' + this.objectApiName); // this does not WORK ??
}
}