You need to sign in to do that
Don't have an account?
Andee Weir 17
Passing parameters from vfp to lightning component
Hi all,
I've read other postings about how to pass parameters from a visualforce page to a lightning component but cannot get it to work. In my case I have created my own custom version of a related list as a lightning component (All Financial Accounts in Third Party's Hierarchy) but want to add the functionality that if there are more than 6 items, the View All link at the bottom of the component opens up the same component in a new page with slightly different paramaters so that more columns & rows are shown (similar to normal related list functionality).
I'm attempting to do this by navigating to a new visualforce page which uses lightning:isUrlAddressable but I get a 'Lightning out App error in callback function error' when it trys to display the lightning component. This can be demonstrated in a cutdown version of the code :
LC1.cmp:
LC1Controller.js :
LC1Container.app :
When I click on Change Parameter I get :
Any suggestions on how get this component to load successfully with the new value of the parameter?
Thanks for any help that can be offered.
I've read other postings about how to pass parameters from a visualforce page to a lightning component but cannot get it to work. In my case I have created my own custom version of a related list as a lightning component (All Financial Accounts in Third Party's Hierarchy) but want to add the functionality that if there are more than 6 items, the View All link at the bottom of the component opens up the same component in a new page with slightly different paramaters so that more columns & rows are shown (similar to normal related list functionality).
I'm attempting to do this by navigating to a new visualforce page which uses lightning:isUrlAddressable but I get a 'Lightning out App error in callback function error' when it trys to display the lightning component. This can be demonstrated in a cutdown version of the code :
LC1.cmp:
<aura:component implements='flexipage:availableForAllPageTypes, lightning:isUrlAddressable' access='global'> <aura:attribute name="param1" type="String" default="AAA"/> <p>{!v.param1}</p> <a href="javascript:void(0);" onclick="{!c.changeParam}">Change Parameter</a> </aura:component>
LC1Controller.js :
({ changeParam : function(component, event, helper) { var urlEvent = $A.get("e.force:navigateToURL"); urlEvent.setParams({ "url":"/apex/VfPage?param1=BBB" }); urlEvent.fire(); } })VfPage.vfp :
<apex:page > <apex:includeLightning /> <script> $Lightning.use("c:LC1Container", function() { $Lightning.createComponent("c:LC1", { "param1" : "BBB" // Removing this still has the same error }, "lightning", function(cmp) { console.log('Component created'); }); }); </script> {!$CurrentPage.parameters.param1} </apex:page>
LC1Container.app :
<aura:application access="GLOBAL" extends="ltng:outApp" > <aura:dependency resource="c:LC1"/> </aura:application>I then added LC1 to the top of the Account's Lightning Page | Related List tab. The end result looks like :
When I click on Change Parameter I get :
Any suggestions on how get this component to load successfully with the new value of the parameter?
Thanks for any help that can be offered.
LC1.cmp LC1Controller.js
VfPage.vfp
LC1Container.app
All Answers
Create a simple event file and fire the event from the visualforce inside the callback and handle the event back in the lightning component file
I suggest you visit this link, it will help you
http://cloudyworlds.blogspot.com/2016/02/lightning-events-via-visualforce.html
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
LC1.cmp LC1Controller.js
VfPage.vfp
LC1Container.app
LC1.cmp
LC1Controller.js