Skip to content

Instantly share code, notes, and snippets.

@arun12209
Created August 7, 2022 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arun12209/44d6e89279a30825aa20992aa57eb88b to your computer and use it in GitHub Desktop.
Save arun12209/44d6e89279a30825aa20992aa57eb88b to your computer and use it in GitHub Desktop.
({
navigateToActivityRecord : function(component,event,helper,ActivityRecord_ID) {
//Workspace API used to open the activity in sub tabs in console app
var workspaceAPI = component.find("workspace"); //get the workspace component
workspaceAPI.isConsoleNavigation().then(function(response) { //check if it is console app
workspaceAPI.getEnclosingTabId().then(function(tabId) { //get the parent tab id
return workspaceAPI.openSubtab({ //open sub tab
recordId: ActivityRecord_ID, //record id of activity
focus: true, //make the tab in focus
parentTabId : tabId //parent tab
}).then(function(response) {
workspaceAPI.getTabInfo({
tabId: response
}).then(function(tabInfo) {
console.log("The url for this tab is: " + tabInfo.url);
});
})
.catch(function(error) { //catch errors
console.log('Error here >> ' + error);
//if(error == 'Error: API `openTab` is not currently supported in this application.'){
var urlEvent = $A.get("e.force:navigateToSObject");
urlEvent.setParams({
"recordId": ActivityRecord_ID,
"isredirect": "true"
});
urlEvent.fire();
});
})
.catch(function(error) {
console.log(error);
});
})
.catch(function(error) {
console.log('catch : '+ JSON.stringify(error));
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment