I am trying to avoid hacking urls so I am using force:navigateToSObject. The only problem is what you cannot Cmd+click or Right click + "Open Link In new Tab" to navigate to the object in a new tab. This seems like something that should be already implemented. Anyone have a work around with force:navigateToSObject?
-
That's because it's not html but javascript so I don't know if it's possible to right click and open link in new tab. You can however use navigatetosobject so that it opens in a new tab, but if you want the user to be able to choose, then I don't know.– AequitasDec 21, 2017 at 22:31
3 Answers
Best approach will be to use Salesforce Lightning Console App.
Lightning console app has tabbed structure. They even have an API to open new tabs.
You can use navigateToURL event.
Maintain a base URL like https://test-salesforceBaseURL.com/
Append a relative URL by adding the ID of the record which you want to redirect
var baseURL = 'https://test-salesforceBaseURL.com/';
var recordId = /*recordID*/
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": baseURL+recordId
});
urlEvent.fire();
force:navigateToSObject is a lightning event. Lightning is a single web application. Lightning is not ready to open new tabs, because in the lightning's first load it load a lot of information.
You can use javascript to open it in a new tab, but i think that it is a wrong approach.
There is the trailhead of lightning alternatives to javascript buttons