[SalesForce] Lightning App Page – pass parameters

I have Lightning App Page created using App Builder with diffrent components embedded into it which is being invoked from a VF page. I would like to pass parameters to the page which will be used by the embedded components to fetch data from SF database and these components have attributes defined. I was passing parameters in the URL to the app page and hoping that I can read them from these components but I could not.

I also tried obtaining them using v.pageReference.state but no success.

Finally I thought the only way is using window.location in the components and obtain them.

Is this the way only we can obtain URL parameters in lightning components embedded in a Lighting App Page created using App Builder??

Best Answer

You need to utilize Application Events here.

Create an application event with parameters, and then set those parameters and fire the application event from your VF page. Handle that event in your lightning components and accordingly perform further operation.

Take a look on Firing Lightning Events from Non-Lightning Code, which explains as how you can utilize this approach with examples.

Related Topic