Hi ,
To access tabs or sub tabs information in Salesforce Classic console application we have Console Integration Toolkit.
In the same way to access tabs or sub tabs information in Lightning Conosle Application we have to use "workspaceAPI".
To access methods of "workspaceAPI" we have to create an instance of the lightning:workspaceAPI component and assign an aura:id attribute to it as shown below .
<lightning:workspaceAPI aura:id="workspace"/>
This component allows you to access methods for programmatically controlling workspace tabs and subtabs in a Lightning console app. In Lightning console apps, records open as workspace tabs and their related records open as subtabs.
To access tabs or sub tabs information in Salesforce Classic console application we have Console Integration Toolkit.
In the same way to access tabs or sub tabs information in Lightning Conosle Application we have to use "workspaceAPI".
To access methods of "workspaceAPI" we have to create an instance of the lightning:workspaceAPI component and assign an aura:id attribute to it as shown below .
<lightning:workspaceAPI aura:id="workspace"/>
This component allows you to access methods for programmatically controlling workspace tabs and subtabs in a Lightning console app. In Lightning console apps, records open as workspace tabs and their related records open as subtabs.
Scenario:
When a record is opened in Lighning Console application we should be able to find out the record ID from the record tab, for further process from application utility menu items.
Eg:
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:appHostable"
access="global" controller="UpdateCaseController">
<lightning:workspaceAPI aura:id="workspace" />
<aura:attribute name="recordId" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>
JSController:
({
doInit : function(component, event, helper) {
var workspaceAPI = component.find("workspace");
workspaceAPI.getTabInfo().then(function(response) {
var action = component.get("c.updateCase");
action.setParams({"caseRecordId":response.recordId});
action.setCallback(this,function(data){
var result = data.getReturnValue();
});
$A.enqueueAction(action);
});
})
Apex Controller:
public class UpdateCaseController{
@Auraenabled
public static void updateCase(String caseRecordId){
Case caseObj = new Case(Id=caseRecordId,ownerId=UserInfo.getUserId());
update caseObj;
}
}
Reference:
https://developer.salesforce.com/docs/component-library/bundle/lightning:workspaceAPI/documentation
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_methods_lightning_tabs.htm
Thanks for post.It's truly informative will surely keep visiting the website.
ReplyDeleteSalesforce opportunity in Newyork
salesforce online trainings in NewYork