getAllUtilityInfo() for Lightning Experience

Returns the state of all utilities as an array of utilityInfo objects.

Arguments 

None.

LWC Sample Code 

This component returns the number of utilities in the utility bar using the utilityInfo object.

1import { LightningElement, wire } from 'lwc';
2import { getAllUtilityInfo } from 'lightning/platformUtilityBarApi';
3
4export default class UtilityInfoExample extends LightningElement {
5    utilityCount = 0;
6
7    async handleGetAllUtilityInfo() {
8        try {
9            const utilityInfo = await getAllUtilityInfo();
10            this.utilityCount = utilityInfo.length;
11
12        } catch (error) {
13            // return error
14        }
15    }
16}

To make your component available for use in a utility bar, specify the lightning__UtilityBar target in the component’s configuration file.

Aura Components Sample Code 

This component has a button that, when pressed, retrieves all utilityInfo objects and opens the first utility, ordered by ID.

Component code:

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

Controller code:

1({
2    handleGetAllUtilityInfo : function(component, event, helper) {
3        var utilityBarAPI = component.find("utilitybar");
4        utilityBarAPI.getAllUtilityInfo().then(function(response) {
5            var myUtilityInfo = response[0];
6            utilityBarAPI.openUtility({
7                utilityId: myUtilityInfo.id
8            });
9       })
10        .catch(function(error) {
11            console.log(error);
12        });
13    }
14})

Response 

For both LWC and Aura Components, this method returns a promise that resolves to an array of utilityInfo objects, containing the following fields. The promise is rejected on error.

NameTypeDescription
idstringThe ID of the utility.
isLoadedbooleanWhether the utility is loaded.
utilityLabelstringThe label of the utility.
utilityIconstringThe SLDS icon ID of the utility’s icon.
utilityIconVariantstringThe SLDS icon variant of the utility’s icon.
utilityHighlightedbooleanWhether the utility is highlighted.
utilityVisiblebooleanWhether the utility is visible.
utilityPoppedOutbooleanWhether the utility is popped out.
panelHeaderLabelstringThe label of the utility panel.
panelHeaderIconstringThe SLDS icon ID of the utility panel’s icon.
panelHeaderIconVariantstringThe SLDS icon variant of the utility panel’s icon.
panelHeightintegerThe height of the utility panel in pixels.
panelWidthintegerThe width of the utility panel in pixels

See Also