Some time we need to open utility bar when lightning app is loaded. This is required when we want to run some background job like update user record or initialize user session when page is loaded.
Use Case:
SalesforceCodex.com is running multi program health system built on Salesforce Platform. Business want when user will open lightning app they will get program selection screen.
Solution:
To handle this business requirement, we can use lightning utility bar. We can put lightning component in utility bar. When lightning app will be loaded that lightning component will open automatically.
We have to check flag ‘Start Automatically‘ for lightning component in utility bar.
Let us see lightning component code which will show program selection on page load.
We have to use getAllUtilityInfo of lightning:utilityBarAPI to get current utility bar and then open that utility bar.
Test Page:
References:
https://developer.salesforce.com/docs/component-library/bundle/lightning:utilityBarAPI/documentation
https://developer.salesforce.com/docs/component-library/bundle/lightning:combobox/example
1 comment
[…] I have LWC Component and I need to open the utility page on the connectedCallback of the page: Somewhat like this: https://salesforcecodex.com/salesforce/open-utility-bar-on-lightning-app-load/ […]