openUtility() for Lightning Experience
Opens a utility. If the utility is already open, this method has no effect. Only one utility can be open at a time. If another utility is already open, openUtility() minimizes the utility. This method isn’t supported for Lightning Web Components (LWC).
For LWC usage, see open() .
Arguments
Name Type Description utilityIdstring The ID of the utility to open. Optional when called within a utility.
Aura Components Sample Code
This component, when added to a single-column Lightning page used in a utility bar, opens the utility when the button is pressed.
Component code:
1 < aura:component implements = "flexipage:availableForAllPageTypes" access = "global" >
2 < lightning:utilityBarAPI aura:id = "utilitybar" />
3 < lightning:button label = "Open Utility" onclick = "{! c.handleOpenUtility }" />
4 </ aura:component >
Controller code:
1 ( {
2 handleOpenUtility : function ( component , event , helper ) {
3 var utilityAPI = component . find ( "utilitybar" ) ;
4 utilityAPI . openUtility ( ) ;
5 }
6 } )
This example opens a utility from outside of the utility, using the utilityId field.
Component code:
1 < aura:component implements = "flexipage:availableForAllPageTypes" access = "global" >
2 < lightning:utilityBarAPI aura:id = "utilitybar" />
3 < lightning:button label = "Open First Utility" onclick = "{! c.openFirstUtility }" />
4 </ aura:component >
Controller code:
1 ( {
2 openFirstUtility : function ( component , event , helper ) {
3 var utilityAPI = component . find ( "utilitybar" ) ;
4 utilityAPI . getAllUtilityInfo ( ) . then ( function ( response ) {
5 var myUtilityInfo = response [ 0 ] ;
6 utilityAPI . openUtility ( {
7 utilityId: myUtilityInfo . id
8 } ) ;
9 } )
10 . catch ( function ( error ) {
11 console . log ( error ) ;
12 } ) ;
13 }
14 } )
Response
This method returns a promise that, upon success, resolves to true.