[SalesForce] Passthrough Page Fails to Redirect in Service Console

I am currently having an issue with my custom passthrough page where it operates correctly but, only when it is outside the service console.

So when I am in the service console, any redirect functionality (filling URL values before going to a custom VisualForce page) no longer works.

So my question is, has anyone run into this issue? If so, how did you manage to resolve it?

I have tried researching it but, haven't found any actual solutions to solve the problem online.

Passthrough Controller Code

Note: I altered the code slightly, not to reveal anything comromising


public with sharing class MyPassthroughController 
{
    private ApexPages.StandardController CurrentStandardController { get; set; }
    private sObject CurrentsObject { get; set; }
    private final Set RecordTypesSet { get; set; }

     public MyPassthroughController (ApexPages.StandardController ControllerToExtend)
     {
        this.CurrentStandardController = ControllerToExtend;   
        this.CurrentsObject = (Example)this.CurrentStandardController.getRecord();

        this.RecordTypesSet = Utilility.RetrieveRecordTypeIdSet('RecordType One;RecordType Two', Schema.sObjectType.Example); 
    }

    public PageReference RedirectByRecordType()
    {
        String ExamplesObjectPrefix = Schema.sObjectType.Example.getKeyPrefix();
        PageReference CorrectRedirectionPage = new PageReference('/' + ExamplesObjectPrefix + '/e?nooverride=1&RecordType=' + this.CurrentsObject.RecordTypeId);

        List Parameters = new List();
        String ReturnURL = ApexPages.currentPage().getParameters().get('retURL');

         if(String.isNotEmpty(ReturnURL))
                Parameters.add( 'retURL=' + ReturnURL);

        if(this.CurrentsObject.Id == null)
        {
            Parameters.add( 'RecordTypeId=' + this.CurrentsObject.RecordTypeId);

            if(this.RecordTypesSet.contains(this.CurrentsObject.RecordTypeId))
                CorrectRedirectionPage = new PageReference( '/apex/CustomEditPage?' + String.join(Parameters, '&'));
        }
        else
            if(this.RecordTypesSet.contains(this.CurrentsObject.RecordTypeId))
              CorrectRedirectionPage = new PageReference( '/apex/CustomEditPage?id=' + this.CurrentsObject.Id);

        return CorrectRedirectionPage;
    }
}

Actual Page Doing Redirect

<apex:page standardController="Example"  showHeader="false" sidebar="false" extensions="MyPassthroughController" action="{!RedirectByRecordType}">
</apex:page>

Hope this code helps clarify things.

Update

Now I am getting a different error that makes more sense.

Now it looks like security is the issue. This is due to only custom VisualForce pages not displaying with the 'This content cannot be displayed in a frame' message

I am getting the dreaded 'This content cannot be displayed in a frame' message. When I choose to 'Open this content in a new window' the correct page opens. So, I am making a little more progress.

Also, I updated the custom URL with URL.getSalesforceBaseUrl().toExternalForm() + '/apex/CustomEditPage?id=' + this.CurrentsObject.Id

Best Answer

This will always happen with VF in the service console.

The workaround I have found is to use a component instead of a VF page. The downside is you will lose the standard controller functionality, but you can always pass in the record in question and any other attributes using attributes.

Also, another thing to note is to undersatnd if your VF/Component is going to be used in both Service Console and non-service console scenarios, in which case you will need to use the force console integration toolkit to open any links in your page as tabs vs taking over the screen (as is normal functionality)

Related Topic