Wednesday, 1 July 2015

How to Refresh a record in Console



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>

Imp Link :- http://www.salesforce.com/us/developer/docs/api_console/Content/sforce_api_console_methods_tabs.htm

2 comments:

  1. Hi Amit,
    thanks for sharing this... really helpful..

    can you please let me know if this can refresh the parent window instead of refreshing the pop window?

    In My case ,we have a custom button, on click of which a pop up opens and some picklist selections are made on that pop up page, when user clicks save , it should close the pop up window and at the same time it should refresh the parent window with newly selected values...

    When i am using your code, it is not updating the parent window but it is refreshing the pop up window.....

    Can you please help ??

    Regards,
    Nidhi

    ReplyDelete
  2. Tried this but primary tab didn't refresh. Any ideas?

    ReplyDelete