Thursday, 25 March 2021

How to override tab name in console application

 Hi,

Here we are going to learn how to override tab name in console application when tab is loaded.

For that we have to create a background utility lightning component and add it into your application utility items.

Sample Component:

utililycomponent.cmp

<aura:component implements="flexipage:availableForAllPageTypes,lightning:backgroundUtilityItem" access="global" >

    <lightning:workspaceAPI aura:id="workspace" />     

    <aura:handler event="lightning:tabCreated" action="{! c.onTabCreated }"/>       

</aura:component>

utililycomponentcontroller.js

{

    onTabCreated: function (component, event, helper) {

        var newTabId = event.getParam('tabId');

        var workspaceAPI = component.find("workspace");

        workspaceAPI.getTabInfo({

            tabId: newTabId

        }).then(function (response) {

               var recId = response.recordId;    

workspaceAPI.setTabLabel({tabId:newTabId, label:'Salesforce Techbook'});

        });

    }

})

This components should include the interface lightning:backgroundUtilityItem to make the lightning component as background utility component.

Here we are using static label. We can make it dynamic as well by calling custom apex class or lightning data service based on record id we are getting in the above code.

Reference:

https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_setTabLabel.htm




No comments:

Post a Comment

Differences between Agentforce for Service and Einstein Bots

 Hi , There are a few differences between Agentforce for Service and Einstein Bots. Agentforce vs. Einstein Bots ...