I'm creating a LWC that I want to have context from the currently focused tab. I want to have both the recordId and the sObjectName.

In fact, I've successfully done this for the recordId based on this answer - it basically involves wrapping the LWC in an Aura component and passing recordId into the LWC from the Aura component.

However, this does not appear to be working for sObjectName, which is another implicit "marker" property. It works when I add the testAura component to a page normally, but not when I add it to the utility bar.

Here's all my code:


<aura:component implements="force:hasRecordId, force:hasSObjectName, flexipage:availableForAllPageTypes, force:lightningQuickAction, lightning:utilityItem" access="global">
    <c:testLwc recordId="{!v.recordId}" sObjectName="{!v.sObjectName}" />


<?xml version="1.0" encoding="UTF-8" ?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <description>Test Aura Component</description>
    <masterLabel>Test Aura Component</masterLabel>


    <div>recordId: <b>{recordId}</b></div>
    <div>sObjectName: <b>{sObjectName}</b></div>


import { LightningElement, api } from 'lwc';

export default class TestLwc extends LightningElement {

    @api recordId;
    @api sObjectName;

    connectedCallback() {
        console.log('recordId:', this.recordId);
        console.log('sObjectName:', this.sObjectName);



<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="KnowledgeSearch">
    <masterLabel>Test LWC</masterLabel>
    <description>Test LWC</description>

And here's a screenshot of the result:

enter image description here

1 Answer 1


The force:hasSObjectName is not supported in the utility bar context.


So you would need to get the object name from the record id. You could call an Apex method that returns sobjectName based on record id.

For example

id recid = '0035e000008WyiAAAS';

You must log in to answer this question.

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