1

This question already has an answer here:

I am trying to refresh the tab once i click on the update button . i have tried in the following way.

<apex:includeScript value="/support/console/22.0/integration.js"/>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</script> 
    <script type="text/javascript">
        function testRefreshPrimaryTabById() {
            //Get the value for 'scc-pt-0' from the openPrimaryTab method
            var primaryTabId = 'scc-pt-0';
            alert("entering");
            sforce.console.refreshPrimaryTabById(primaryTabId, true, refreshSuccess);
            alert("exit");
        }


  </script>

page:

<apex:commandButton action="{!action}"  title="Submit" value="Update" reRender="id1" status="loadStatus"  rendered="{!controls}" oncomplete="testRefreshPrimaryTabById()"/>

but onclick of the update button the tab is not refreshing......

my computer code is:

 <script type="text/javascript">
function RefreshPrimaryTab() 
        {
            alert('hai');
            sforce.console.getFocusedPrimaryTabId(showTabId);
            alert('hello');
        }

        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>

button

<apex:commandButton action="{!function}" style="margin-left:900px;margin-top:4px;border-color: #e0e5ee;color:#fff;background: #0070d2;height: 32px;width:86px;" 
     title="Submit" value="Update" reRender="id1" status="loadStatus"  rendered="{!controls}" oncomplete="RefreshPrimaryTab();return false"/>

showing the both the alerts hai and hello .....but after that it is not refreshing the console.......

i want to refresh the tab as shown below attachment:

enter image description here

marked as duplicate by Ratan Paul, Vamsi Krishna, Chris Duncombe, Himanshu, crmprogdev Jan 3 '16 at 16:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
<apex:commandButton action="{!action}" oncomplete="testRefreshPrimaryTabById()" title="Submit" 
              value="Update" reRender="id1" status="loadStatus"  rendered="{!controls}" />

Script

<script type="text/javascript">
        function testRefreshPrimaryTabById() {
            //Get the value for 'scc-pt-0' from the openPrimaryTab method
            var primaryTabId = 'scc-pt-0';
            alert("entering");
            sforce.console.getFocusedPrimaryTabId(showTabId);
            alert("exit");
        }
        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>

Edit

VF page

<apex:page standardController="Case" extensions="consoleCtrl">
<apex:form id="frm">
   <apex:includeScript value="/support/console/33.0/integration.js"/>
   <script type="text/javascript">


        function testRefreshPrimaryTabById() {
            //Get the value for 'scc-pt-0' from the openPrimaryTab method
            var primaryTabId = 'scc-pt-0';
            alert("entering");
            sforce.console.getFocusedPrimaryTabId(showTabId);
            alert("exit");
        }
        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>

  <apex:commandButton action="{!action}" style="margin-left:900px;margin-top:4px;border-color: #e0e5ee;color:#fff;background: #0070d2;height: 32px;width:86px;" 
     title="Submit" value="Update" reRender="frm" status="loadStatus"  oncomplete="testRefreshPrimaryTabById();return false"/>
</apex:form>
</apex:page>

Class

public class consoleCtrl {

    public  consoleCtrl(ApexPages.standardController stdCtrl){}
    public void action(){

    }
}

enter image description here

  • on command button the primarytabrefresh function is not working........oncomplete is not working – Dileep Jan 3 '16 at 13:26
  • @user27494 are you getting any error ? check in browser console click F12 and check – Ratan Paul Jan 3 '16 at 13:42
  • not getting any error – Dileep Jan 3 '16 at 13:57
  • please help me out in refreshing that tab shown in attachment......... – Dileep Jan 3 '16 at 14:23
  • hey @user27494 it is working for me..... check my edit in my Ans... that code worked for me – Ratan Paul Jan 3 '16 at 14:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.