function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chaminga Dissanayake 12Chaminga Dissanayake 12 

Passing parameter in Lightning Experience

I need to pass some URL/query parameters between Visualforce pages which are embedded in the lightning app.

Let's assume URL is -
https://cs1.lightning.force.com/one/one.app#/sObject/Opportunity/new?Unit__c=a0Zp0000002mja8ETA&isdtp=p1

So how can I access Unit__c in the controller?

The following code segment is not working with Lightning.
ApexPages.currentPage().getParameters().get('Unit__c')
Shun KosakaShun Kosaka
Hi Chaminga,
Custom lightning app will be needed because attribute is required to get URL/query parameter. Unfortunately, we cannot add attributes to standard app/component in lightning app builder. You can receive url parameter by <aura:attribute> and pass it in iFrame VF page by client-side controller.

Below articles are also useful!
https://developer.salesforce.com/blogs/developer-relations/2017/01/lightning-visualforce-communication.html
http://salesforce.stackexchange.com/questions/106543/lightning-app-getting-url-parameter
Aaron Webster 21Aaron Webster 21

For those who are still looking for a way to do this. I have a salesforce Experience site that has a VisualForce page on it. The VisualForce page is dependent on URL parameters. This is how I retrieved the URL parameter for the site.

 

var url = (window.location != window.parent.location)
                ? document.referrer
                : document.location.href;
const queryString = url.split('?')[1];
const urlParams = new URLSearchParams(queryString);
const sfAccountId = urlParams.get("accountId");
console.log({sfAccountId});