Newer Version Available
getUtilityInfo() for Lightning Experience
Returns the state of the current utility as a utilityInfo object.
Arguments
| Name | Type | Description |
|---|---|---|
| utilityId | string | The ID of the utility for which to retrieve the state. Optional when called within a utility. |
Sample Code
This component has a button that, when pressed, retrieves the enclosing utility’s info and opens it if it’s not currently visible, and closes it otherwise.
Component code:
1<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
2 <lightning:utilityBarAPI aura:id="utilitybar" />
3 <lightning:button label="Get Utility Info" onclick="{! c.getUtilityInfo }" />
4</aura:component>Controller code:
1({
2 getUtilityInfo : function(component, event, helper) {
3 var utilityAPI = component.find("utilitybar");
4 utilityAPI.getUtilityInfo().then(function(response) {
5 if (response.utilityVisible) {
6 utilityAPI.minimizeUtility();
7 }
8 else {
9 utilityAPI.openUtility();
10 }
11 })
12 .catch(function(error) {
13 console.log(error);
14 });
15 }
16})Response
This method returns a promise that, upon success, resolves to a utilityInfo object representing the enclosing utility, containing the following fields.
| Name | Type | Description |
|---|---|---|
| id | string | The ID of the utility. |
| isLoaded | boolean | Whether the utility is loaded. |
| utilityLabel | string | The label of the utility. |
| utilityIcon | string | The SLDS icon ID of the utility’s icon. |
| utilityHighlighted | boolean | Whether the utility is highlighted. |
| utilityVisible | boolean | Whether the utility is visible. |
| panelHeaderLabel | string | The label of the utility panel. |
| panelHeaderIcon | string | The SLDS icon ID of the utility panel’s icon. |
| panelHeight | integer | The height of the utility panel in pixels. |
| panelWidth | integer | The width of the utility panel in pixels |