Could anyone help me
#Javascript #Aura #Aura Component #Salesforce Developer #Salesforce Developers #Salesforce Development #Developer Forums
Someone could help me understand what this function does, please?
redirect: function (childComponent, pageReference, overrideUrl) {
if(this.isCommunityContext()){
let url = this.buildCommunityUrl(pageReference);
window.parent.location.href = url;
}
else{
var self = this;
const { closeTab, getEnclosingTabId, isConsoleNavigation, openSubtab } = childComponent.getSuper().find("workspace");
isConsoleNavigation()
.then(function (response) {
if (response === true) {
getEnclosingTabId().then(function (enclosingTabId) {
openSubtab({
pageReference: pageReference,
focus: true
}).then(function () {
closeTab({
tabId: enclosingTabId
});
}).catch(function (error) {
console.log(error);
});
});
} else {
let navService = childComponent.getSuper().find("navService");
navService.navigate(pageReference, overrideUrl);
}
}).catch(function (error) {
self.handleError(childComponent, error);
});
}
},
Hi Yan,
Despite its rather complex look, this function opens a new page in the browser.
By the looks of it, it should be able to handle navigating to another page within a community context as well as console applications, where it knows to open a new console tab instead of a browser tab.