0

I have a pretty simple Apex Controller + Action which I lifted from Salesforce Sidekick that takes a Flow, skins it up in Lightning Experience, and redirects to the newly created record. The issue I have is that when I use the flow launched from the button with a List Button with a Behavior = 'Display in existing window with sidebar' the final URL is not the true PageReference set in the action. The result is a page within a page showing the header and sidebar within the header and sidebar and the URL ends up looking like '/servlet/servlet.Integration?lid=...'

It works correctly if I use the behavior = 'Display in existing window without sidebar or header'.

I want to show the flow in an existing window and then have the PageReference just return to the new record. How can I accomplish this?

I have tried putting 'sidebar="false" showHeader="false"' in the header but it still doesn't work.

Thanks in advance!

Controller Code:

public with sharing class FlowRedirectController {

public Object FlowRedirectController() { 
    String unique_id    =       ApexPages.currentPage().getParameters().get('id');
    String obj          =       ApexPages.currentPage().getParameters().get('obj');

    if(unique_id == null){

        String url = '/home/home.jsp';
        return new PageReference(url);
    } 

    List<sObject> sobjList = database.query('SELECT Name, Unique_Flow_Identifier__c, Id  FROM '+String.escapeSingleQuotes(obj)+ ' WHERE Unique_Flow_Identifier__c = :unique_id ORDER BY CreatedDate DESC LIMIT 1');
    String returl = sobjList[0].id;


    if (returl == null) {
        // Return Home if no ID 
        String url = '/home/home.jsp'; 
    return new PageReference(url); }


    String url = '/' + returl;
        PageReference pRef = new PageReference(url);
        pRef.setRedirect(true);
    return pRef;}}

VF Page:

<apex:page controller="FlowRedirectController" action="{!FlowRedirectController}" sidebar="false" showHeader="false">

  • can you elaborate on what "doesnt work" ? – glls Dec 5 '17 at 21:23
  • Thanks for the reminder to include important detail. I have updated the post but basically it shows the page within the page with a duplicate header and sidebars. – wadams2010 Dec 5 '17 at 21:40

Your Answer

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

Browse other questions tagged or ask your own question.