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
Brian11Brian11 

Utility BarAPI on the doinit action has no recordId on the component

Hi,

I am using Utility BarAPI and I have the following component below openining when a button is clicked.

These Are the following implements on the Component 

implements="flexipage:availableForAllPageTypes,force:hasRecordId"

To my understanding force:hasRecordId will give you the following variable (recordId) allowing you to know which contact your on.

When I run the code below recordId for some reason its null.  I think its because doInit fires before the component is render so it has no recall of what recordId is. Since This component is hidden inside a utilitybar.  Is there a way around this?

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

let contactId = component.get("v.recordId");
console.log(contactId) => null
Raj VakatiRaj Vakati
Can you try to get the record id from the URL by using token #  and aura:locationChange is depricated but this is an example for you 
aura:application >
    <aura:attribute name="theId" type="Id" />
    <aura:handler event="aura:locationChange" action="c.handleLocationChange"/>
    <ui:outputText value="{!v.theId}" />
</aura:application>

({
    handleLocationChange : function (component, event, helper) {
        var loc = event.getParam("token");
        console.log(loc);
        component.set("{!v.theId}",loc);
    }

})