Print this page

Highlight Panel in Service Console not redering after saving record from Visualforce page

Knowledge Article Number 000230925
Description Issue:
In the Service Console when a record is saved from a Visualforce page it does not automatically redirect the browser to the standard page layout or tab within the console. Because of this the page remains a Visualforce page and the highlight panels are not rendered. This is how the Service Console handles Visualforce pages and additional handling on the page via JavaScript and controller extension is needed for the expected highlight panels to render for the record on save.
Resolution How to Implement For the Highlight Panel to be Rendered in the Service Console:
  • In this example it is creating a new Account record using the Service Console. On selecting the "New Account" button within the Service Console you will be taken to the custom Visualforce page.
Service Console ListView

 
Steps for creating the page for it to properly render the Highlight Panel when saving a record when using a Visualforce page in the Service Console:
  1. Create custom Visualforce page: (Note you will need to add the JavaScript within the page for this to work)
VF Page: VFNewAccount

<apex:page standardController="Account" extensions="AccountExtension">
    <script>
        Sfdc.support.servicedesk.isVisualforcePage = function (url)
        {
            var domain = Sfdc.Url.getHostFromUrl(url),
            domainsToCheck = Sfdc.support.servicedesk.serviceDeskConfig.trustedDomains, i,
            // note that length needs to be set to 2
            length = 2;

            if (url)
            {
                for (i = 0; i < length; i++)
                {
                    if (domain.indexOf(domainsToCheck[i]) !== -1 && url.indexOf('/apex/') !== -1)
                    {
                        return true;
                    }
                }
            }

            return false;
        };
        ...
        /**
        * Inspect the url to infer type of entity the url deals with.
        * It looks for standard sfdc uri patterns such as [00x...?, 00x.../, 00x...,].
        * For non-standard urls, such as VF, the result may not be related to entity at all.
        * For record type and territory management urls, looks for id and/or pid parameter.
        */
        Sfdc.support.servicedesk.getEntityInfoFromUrl = function(url) {
            var eid = null;
        ...
        } else if (Sfdc.support.servicedesk.isChatterAnswer(url)
        || Sfdc.support.servicedesk.isIdeaViewUrl(url)
        || Sfdc.support.servicedesk.isVisualforcePage(url)) {
        eid = url.match(Sfdc.support.servicedesk.VF_ENTITY_ID_PARAM_REGEXP);
        } else {
        eid = url.match(Sfdc.support.servicedesk.ENTITY_ID_REGEXP);
        }
        return (eid === null) ? '' : typeof eid == 'string' ? eid : eid[1];
        };
    </script>
    <apex:form >
        <apex:pageBlock title="Quick Create Account">
            <apex:pageBlockSection title="Account Details" columns="1">
                <apex:inputField value="{!Account.Name}"/>
                <apex:inputField value="{!Account.Fax}"/>
                <apex:inputField value="{!Account.Type}"/>
                <apex:inputField value="{!Account.Phone}"/>
                <apex:inputField value="{!Account.Website}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
  1. Change the "New" Button to use your Visualforce page (In this example it would be VFNewAccount)
  •  Go to Setup-> Accouts-> Buttons, Links, and Actions-> Edit "New button with VF page
  1. Create a new Visualforce page to determine whether to route to a tab in Console if request is called from the console, or to standard page layout if the request is not made from the Service Console.
VF Page: RefreshPage

<apex:page standardController="Account">
    <apex:includeScript value="/support/console/28.0/integration.js"/>
    <script>
        if (sforce.console.isInConsole()) {
        var openTab = function openTab(result) {
            var tabId = result.id;
            sforce.console.openPrimaryTab(tabId, '/{!Account.ID}?isdtp=vw', true);
        };
        sforce.console.getEnclosingPrimaryTabId(openTab);
        } else {
         window.top.location= '{!URLFOR($Action.Account.View, Account.ID)}';

        }       
    </script>
</apex:page>
 
  1. Create an Apex Controller Extension (In this case we are extending the standard Account controller)
Apex: AccountExtension

public class AccountExtension {

    private final Account acct;
    public boolean isInConsole {get; set;}
    
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard controller.
    public AccountExtension(ApexPages.StandardController stdController) {
        this.acct = (Account)stdController.getRecord();

    }

    public PageReference save() {
        try {
            insert(acct);
        } catch(System.DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
                
        PageReference refreshPage = new PageReference('/apex/RefreshAccountPage');
        return refreshPage;
    }
}




promote demote