Per the force:hasSObjectName interface documentation, I can reference an automatically added attribute named sObjectName to retrieve the object where my custom lightning component is being accessed. However when I try to use this value, it is undefined (code below): Is this the correct way to reference the sObjectName? I'm aware I can pull this value from the record id, but I'd like to know what I'm doing wrong.
Lightning Component
<aura:component controller="lc_BuyerSellerSearchCriteriaCTRL" implements="force:hasSObjectName,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" description="lc_BuyerSellerSearchCriteriaDynamic" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<!--Component Code-->
</aura:component>
Component Controller
init: function(cmp, event, helper) {
console.log(cmp.get('v.sObjectName'));
}
This statement in the console log shows undefined
init
function which is blocking the component to be rendered completely. I can confirm that it works if added to a custom tab.