4

I have built in some VF pages which are embeded in the page layout. These pages have some buttons on it which redirect to a new page.

For the page to open in the same page and not within the iframe i have used the javascript windows.top. Now this would not work on the new lightning UI as it would overwrite the lightning container.

I am pretty sure this is a use case for many existing applications. Is there a workaround or ideas to open the new page within the lightning container, but within the iframe holding the VF page in pageLayout

3

When you're in Lightning Experience, you should rely on sforce.one to manage navigation for you. Not only navigation will work, but also navigation history will be saved correctly.

Unfortunately, sforce.one isn't available in Salesforce Classic, so if your Visualforce page needs to be exposed both on Lightning Experience and Salesforce Classic, you'll need to create a function to handle both cases.

For instance, if you want to create a button that redirect you to an Account creation page, you can do something like this:

function createAccount() {
    if ((typeof sforce != 'undefined') && sforce && (!!sforce.one)) {
        // Manage navigation in Lightning Experience & Salesforce1
        sforce.one.createRecord('Account');
    }
    else {
        // Manage navigation in Salesforce Classic
        window.top.location = '{!URLFOR($Action.Account.New)}';
    }
}

Then, you'll need to call this function on your button:
<apex:commandButton onclick="createAccount();" value="Navigate"/>

You can have a look to sforce.one documentation for your other use cases (display a record, edit one...): https://developer.salesforce.com/docs/atlas.en-us.salesforce1.meta/salesforce1/salesforce1_dev_jsapi_sforce_one.htm

Also, there is a Trailhead about Lightning Experience and Visualforce, with a specific focus on navigation. https://developer.salesforce.com/trailhead/lex_dev/lex_dev_visualforce/lex_dev_visualforce_navigation I encourage you to have a look to the whole module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.