Skip to main content

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);

});

}

},

1 Antwort
  1. 5. Aug. 2021, 07:08

    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.

0/9000