I need to put a Button in the record Detail View that executes some code through aura componenet.
I've generated a lightning app and put it into a visualforce page that has been set behind the button.
<apex:page showHeader="true" sidebar="true" standardcontroller="Lead">
<apex:includeScript value="/lightning/lightning.out.js" />
<div id="lightning" />
<script>
$Lightning.use("c:ExposeChangeOwnerVF", function() {
$Lightning.createComponent("c:CambioOwner",
{ label : "",
recordId : '{!Lead.Id}' },
"lightning",
function(cmp) {
});
});
</script>
Now I want to refresh the page after the component has done the callback:
if(state === "SUCCESS"){
console.log('step 3');
$A.get("e.force:refreshView").fire();
But when I click the button I get this error:
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://CambioOwner_Controller/ACTION$changeOwnerForSelectedRecord Failing descriptor
It seems that the problem shows up only when I embed the component into the visualforce through the lightning app, but If I use it as a quick action it work without any errors.
Do you have any suggestion?
Best Answer
Lightning statndard events like $A.get("e.force:refreshView").fire(); are not supported when lightning component is used in visual force pages.