Skip to content

Instantly share code, notes, and snippets.

@winniecluk
Created January 3, 2018 20:35
Show Gist options
  • Select an option

  • Save winniecluk/4e4f773ce89fee432812df899caf70e0 to your computer and use it in GitHub Desktop.

Select an option

Save winniecluk/4e4f773ce89fee432812df899caf70e0 to your computer and use it in GitHub Desktop.
<!-- app event -->
<aura:event type="APPLICATION" description="Used to Redirect to a Record within VF" >
<aura:attribute type="String" name="recordId" />
<aura:attribute type="String" name="target" />
</aura:event>
<!-- lightning component -->
<aura:registerEvent name="redirectToRecord" type="c:redirecttorecord" />
<!-- lightning controller -->
var redirectEvt = $A.get('e.c:redirectToRecord');
redirectEvt.setParams({
"recordId": event.target.dataset.id
, "target": ''
});
redirectEvt.fire();
<!-- VF page -->
$Lightning.use("c:accountEquipmentApp", function() {
$Lightning.createComponent(
"c:accountEquipment",
{ recordId : "{!Account.Id}" },
"lightning",
function() {
$A.eventService.addHandler(
{ "event": "c:redirectToRecord",
"handler" : redirectPage
});
}
);
});
function redirectPage (event){
console.log('inside redirect page on VF page');
var urlEvent = $A.get('e.force:navigateToURL');
var recordId = event.getParam("recordId");
var url = '/' + recordId;
if (urlEvent){
urlEvent.setParams({
url: url
});
urlEvent.fire();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment