In the end it was sufficient for us to assume that the screen was being launched from the List View. If we need variations then I think we'll try to make a VF component and wrap that with different pages for different contexts. We'll cross that bridge when we come to it.
For now we have the following on the VF controller:
public String getReferer(){
Id filterId = setController.getFilterId();
String baseUrl = ApexPages.currentPage().getHeaders().get('Referer');
String fullUrl = baseUrl + 'one/one.app#/sObject/Contact/list?filterName=' + filterId;
return fullUrl;
}
In the VF we then pass a handler into the component when we construct it:
closePopoverHandler = function( event ) {
window.top.location = '{!referer}' ;
};
$Lightning.use( "c:OurLightningApp", function() {
$Lightning.createComponent( "c:OurLightningComponent",
{ param1: 'value1' },
"DivToReplace",
function(cmp) {
$A.eventService.addHandler({
event: 'force:closeQuickAction',
handler: closePopoverHandler
});
});
});
And then ensure that the LightningApp has the following dependancy:
<aura:dependency resource="markup://force:*" type="EVENT"/>
That said, as an alternative for finding the URL to return to - a more generic solution would be to use the ApexPages parameters, which sometimes contains the return url.
String retUrl = ApexPages.currentPage().getParameters().get('vfRetURLInSFX' );
if ( String.isNotEmpty( retUrl ) ) {
//
// the retUrl is in the parameters, so we should just return it
//
return retUrl;
}
//
// We can assume have been launched from a related list on an object, and so the url has to be constructed
//
String baseUrl = ApexPages.currentPage().getHeaders().get('Referer');
return baseUrl + 'one/one.app#/sObject/' + apexpages.currentpage().getparameters().get('id');
Best Answer
<outputlink/>
would translate to classic URL which doesn't work in Lightning or it redirect to classic user interface.In Lightning, navigation does not vary org to org. You only need to pass the Sobject name only. For Account just set up the url as: