0

When I call the method refreshPrimaryTabById is the highlight panel supposed to refresh too?

I'm not able to figuring out why it doesn't refresh while the primary tab does.

1 Answer 1

2

Basically my problem was 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
  4. view 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!

This is the best way i found to reproduce the standard experience with Service Console.

<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>

Hope this will be useful to you ;)

3
  • Hi, Sub tab is closed first. The "afterRefresh" is happening first then openConsoleURL is happening, the sub tab which i opened was a VF page in my case, Once the primary tab refreshes , the VF Page is reopened again via OpenConsoleURL. The primary tab is refreshing fine. I would like to know how to prevent Sub tab from opening again. TIA
    – AjaySFDC
    Jan 6, 2016 at 9:21
  • With this work around is not possible :( This is because with openConsoleUrl you are "refreshing" the state of primary tab that consequently refresh also the subtab.
    – Marco
    Jan 7, 2016 at 18:04
  • Is it possible to Close the subtab after page has been loaded fully and refresh had happened ? Bcoz this wud resolve my issue .. I tried alot of things like SetTimeout , Closetab() focussedsubtab() functions etc. But it din work for me :/
    – AjaySFDC
    Jan 11, 2016 at 17:46

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.