Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

getEnclosingUtilityId() for Lightning Experience

Returns the ID of the enclosing utility, or false if not within a utility. This method isn’t supported for Lightning Web Components (LWC).

Arguments

None.

Aura Components Sample Code

This component has a button that, when pressed, retrieves the enclosing utility’s ID.

Component code:

1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2    <lightning:utilityBarAPI aura:id="utilitybar" />
3    <lightning:button label="Get Enclosing Utility ID" onclick="{! c.handleGetEnclosingUtilityId }" />
4</aura:component>

Controller code:

1({
2    handleGetEnclosingUtilityId : function(component, event, helper) {
3        var utilityAPI = component.find("utilitybar");
4        utilityAPI.getEnclosingUtilityId().then(function(utilityId) {
5            console.log(utilityId);
6        })
7        .catch(function(error) {
8            console.log(error);
9        });
10    }
11})

Response

This method returns a promise that, upon success, resolves to the utilityId of the enclosing utility or false if not within a utility.