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
Marco ZeuliMarco Zeuli 

Service Cloud Console - Highlight panel not refreshing

Hi guys,

today i'm facing a problem with the highlight panel in the Service Cloud Console.
Basically the problem is this:
  1. I open a Case as a sub tab of an Account record
  2. Highlight panel opens with some Accounts fields
  3. Click Edit button on Case detail view
  4. Edit button send the sub tab to a custom VF page to edit Case fields
  5. Click Save button on VF page to store Case data
  6. Before the VF page unload, i call from javascript the function to refresh the primary tab. That's because when i save a Case the controller action executed modify also some fields on the Account record
  7. If i click on the Deatil subtab of the Account record i can see the fields correctly updated.
  8. but the same field on the highlight panel shows the old value!
So my question is: is the call 
sforce.console.refreshPrimaryTabById
supposed to refresh also the data in the highlight panel? Is that possible that the user has to refresh the entire console to see that fields correctly updated ?!

Thanks guys ;)
 
Best Answer chosen by Marco Zeuli
Marco ZeuliMarco Zeuli
This is the best way i found to reproduce the standard experience:
 
<apex:page standardController="Case" extensions="Case_extension" tabStyle="Case">

<script src="/support/console/34.0/integration.js" type="text/javascript"></script>
<script type="text/javascript">

        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
            console.log('getting primary tab id');
            sforce.console.getEnclosingPrimaryTabId(getPrimaryTabId);
            console.log('getting current subtab id');
            sforce.console.getEnclosingTabId(getSubtabId);
        });

        /*
         *   Called when user press "Salva" button.
         *   If page was loaded in console close and open current primary tab
         *   to refresh Account indicators, righside and leftside bar
         */
        function setBeforeUnloadEvent() {
            window.onbeforeunload = function(e) {
                if (sforce.console.isInConsole() && '{!Case.Id}') {
                    //First find the ID of the current tab to close it
                    console.log('refreshing');
                    refreshTabsAfterSave();
                }
            }
        }

        function refreshTabsAfterSave () {
            console.log('getting link');
            sforce.console.getTabLink(sforce.console.TabLink.PARENT_AND_CHILDREN, currentPrimaryTabId, refreshPrimaryTab);
        }

        var refreshPrimaryTab = function refreshPrimaryTab (res) {
            console.log('tab link is: ', res);

            sforce.console.openConsoleUrl(currentPrimaryTabId, res.tabLink, true, [], [], afterRefresh);
        }

        var currentSubTabId; // set on page load
        var currentPrimaryTabId; // set on page load

        var getPrimaryTabId = function getPrimaryTabId (result) {
            console.log('primary tab id is: ', result.id);
            currentPrimaryTabId = result.id;
        }

        var getSubtabId = function getSubtabId (result) {
            console.log('sub tab id is: ', result.id);
            currentSubTabId = result.id;
        }

        var afterRefresh = function afterRefresh (res) {
            console.log('after refresh, get enclosing tab');
            sforce.console.getEnclosingTabId(getEnclosingTab);
        }

        var getEnclosingTab = function getEnclosingTab (res) {
            console.log('enclosing tab is: ', res.id);
            sforce.console.closeTab(res.id);
        }
    </script>

<apex:form>
  <apex:pageblock>

   <apex:pageBlockButton>
      <apex:commandButton value="Save" action="{!customSave}" onclick="setBeforeUnloadEvent()"  />
   </apex:pageBlockButton>
   

   <!--- all your page code --->
</apex:page>

Basically when user press the Save button, an onBeforeUnload event handler is set. This way when controller method customSave return the new page reference (in my case standard case view page) the whole primary tab, including all his subtab, will be refreshd and you will see an updated Highlight panel.

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please check below blog . May be that will help u
http://amitsalesforce.blogspot.in/2015/07/how-to-refresh-record-in-console.html

Include JS in VF page
<apex:includeScript value="/support/console/26.0/integration.js"/>

Then use below link to open new record 
<A HREF="#" onClick="RefreshPrimaryTab();return false">         Click here to refresh </A>
Write below Java Script code in VF page
<script type="text/javascript">
    
        function RefreshPrimaryTab() 
        {
            sforce.console.getFocusedPrimaryTabId(showTabId);
        }
            
        var showTabId = function showTabId(result) 
        {
            var tabId = result.id;
            alert('Primary Tab IDs: primaryTabId ' + tabId );
            sforce.console.refreshPrimaryTabById(tabId , true, refreshSuccess);
        };
                   
        var refreshSuccess = function refreshSuccess(result) 
        {
            //Report whether refreshing the primary tab was successful
            if (result.success == true) 
            {
                alert('Primary tab refreshed successfully');
            } 
            else 
            {
                alert('Primary did not refresh');
            }
        };
       
    </script>
Please let us know if this will help you


 
Marco ZeuliMarco Zeuli
Thanks Amit, but that's exactly what i was doing :(
Yeasterday i figured out how to reproduce the standard experience i'll post the code here ;)
Marco ZeuliMarco Zeuli
This is the best way i found to reproduce the standard experience:
 
<apex:page standardController="Case" extensions="Case_extension" tabStyle="Case">

<script src="/support/console/34.0/integration.js" type="text/javascript"></script>
<script type="text/javascript">

        var j$ = jQuery.noConflict();
        j$(document).ready(function() {
            console.log('getting primary tab id');
            sforce.console.getEnclosingPrimaryTabId(getPrimaryTabId);
            console.log('getting current subtab id');
            sforce.console.getEnclosingTabId(getSubtabId);
        });

        /*
         *   Called when user press "Salva" button.
         *   If page was loaded in console close and open current primary tab
         *   to refresh Account indicators, righside and leftside bar
         */
        function setBeforeUnloadEvent() {
            window.onbeforeunload = function(e) {
                if (sforce.console.isInConsole() && '{!Case.Id}') {
                    //First find the ID of the current tab to close it
                    console.log('refreshing');
                    refreshTabsAfterSave();
                }
            }
        }

        function refreshTabsAfterSave () {
            console.log('getting link');
            sforce.console.getTabLink(sforce.console.TabLink.PARENT_AND_CHILDREN, currentPrimaryTabId, refreshPrimaryTab);
        }

        var refreshPrimaryTab = function refreshPrimaryTab (res) {
            console.log('tab link is: ', res);

            sforce.console.openConsoleUrl(currentPrimaryTabId, res.tabLink, true, [], [], afterRefresh);
        }

        var currentSubTabId; // set on page load
        var currentPrimaryTabId; // set on page load

        var getPrimaryTabId = function getPrimaryTabId (result) {
            console.log('primary tab id is: ', result.id);
            currentPrimaryTabId = result.id;
        }

        var getSubtabId = function getSubtabId (result) {
            console.log('sub tab id is: ', result.id);
            currentSubTabId = result.id;
        }

        var afterRefresh = function afterRefresh (res) {
            console.log('after refresh, get enclosing tab');
            sforce.console.getEnclosingTabId(getEnclosingTab);
        }

        var getEnclosingTab = function getEnclosingTab (res) {
            console.log('enclosing tab is: ', res.id);
            sforce.console.closeTab(res.id);
        }
    </script>

<apex:form>
  <apex:pageblock>

   <apex:pageBlockButton>
      <apex:commandButton value="Save" action="{!customSave}" onclick="setBeforeUnloadEvent()"  />
   </apex:pageBlockButton>
   

   <!--- all your page code --->
</apex:page>

Basically when user press the Save button, an onBeforeUnload event handler is set. This way when controller method customSave return the new page reference (in my case standard case view page) the whole primary tab, including all his subtab, will be refreshd and you will see an updated Highlight panel.
This was selected as the best answer
Kos Mitev 15Kos Mitev 15
I have the same problem however I cannot exactly implement the workaround provided because I cannot add the 
onclick="setBeforeUnloadEvent()"
even handler to the save button because the custom VF page with which I am overriding my "Edit" button comes from a managed package.
Does anybody know a better workaround or a workaround which I can implement in my scenario?

Marco Zeuli thank you very much for posting the solution.