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
SurekaSureka 

refreshPrimarytabById not working in service console

Hi,

I am trying to refresh a case record tab from an inline VF page in Case. I am fetching the corresponding case tab Id using "enclosingPrimaryTab" and trying to refresh the corresponding case record tab. "refreshPrimaryTabById" not working in this case. 

Has anyone tried using "refreshPrimaryTabById"? Please provide your suggestion. 

Thanks
Sureka
Best Answer chosen by Sureka
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help 
<apex:page standardController="Case">
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">
	<script type="text/javascript">
        function RefreshPrimaryTab(id) 
        {
             if (sforce.console.isInConsole())
                  sforce.console.getFocusedPrimaryTabId(showTabId);
             else
                  window.top.location.href = '/' + id;
        }

        var showTabId = function showTabId(result) 
        {
            var tabId = result.id;
            sforce.console.refreshPrimaryTabById(tabId , true);
        };
	</script>

<A HREF="#" onClick="RefreshPrimaryTab('{!Case.id}'); return true;">         Click here to refresh </A>
</apex:page>

You can call the js code by Button so like below :-

<apex:commandButton value="Refresh Agreements" action="{!DummyFnction}" oncomplete="RefreshPrimaryTab('{!case.id}'); return true;" status="waitStatus" />

Please let us know if this will help u
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Hi Sureka,

Please check below blog. I hope that will help you.
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="testRefreshPrimaryTabById();return false">         Click here to refresh </A>
Write below Java Script code in VF page
<script type="text/javascript">
    
        function testRefreshPrimaryTabById() 
        {
            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

Thanks
Amit Chaudhary
SurekaSureka
Hi,

I have the following code as inline VF page in Case detail page. It displays "Primary Tab Id". But it says, "Primary Tab did not refresh". 

<apex:page standardController="Case">
<A HREF="#" onClick="testTabRefresh();return false">
    Click here to refresh this tab</A>
    {!now()}
<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript">
    function testTabRefresh() {
        sforce.console.getEnclosingTabId(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) 
        {
            if (result.success == true) 
            {
                alert('Primary tab refreshed successfully');
            } 
            else 
            {
                alert('Primary did not refresh');
            }
        };
</script>
</apex:page>

I want to refresh Case detail page from inline VF page in console. Please let me know if that is possible. 

Thanks
SurekaSureka
Hi Amit,

Thanks for the reply. But it executes the else part and says "Primary did not refresh".

Thanks
SurekaSureka
Hi Amit,

Thanks for your quick reply. I have added that. Still it says "Primary did not refresh".
Is it something to do with version of VF page? my VF page version is 34. 

<apex:page standardController="Case">
<A HREF="#" onClick="testTabRefresh();return false">         Click here to refresh </A>

<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">
    function testTabRefresh() {
        sforce.console.getEnclosingTabId(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) 
        {
            if (result.success == true) 
            {
                alert('Primary tab refreshed successfully');
            } 
            else 
            {
                alert('Primary did not refresh');
            }
        };
</script>
</apex:page>

Thanks
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help 
<apex:page standardController="Case">
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">
	<script type="text/javascript">
        function RefreshPrimaryTab(id) 
        {
             if (sforce.console.isInConsole())
                  sforce.console.getFocusedPrimaryTabId(showTabId);
             else
                  window.top.location.href = '/' + id;
        }

        var showTabId = function showTabId(result) 
        {
            var tabId = result.id;
            sforce.console.refreshPrimaryTabById(tabId , true);
        };
	</script>

<A HREF="#" onClick="RefreshPrimaryTab('{!Case.id}'); return true;">         Click here to refresh </A>
</apex:page>

You can call the js code by Button so like below :-

<apex:commandButton value="Refresh Agreements" action="{!DummyFnction}" oncomplete="RefreshPrimaryTab('{!case.id}'); return true;" status="waitStatus" />

Please let us know if this will help u
 
This was selected as the best answer
SurekaSureka
Hi Amit,

Thanks a lot. It works :).

Is there a way to identify if a code is executed from console in Apex?

Thanks
SurekaSureka

Hi Amit,

Thanks a lot. It works :).

Is there a way to identify if a code is executed from Service console in Apex?

Thanks
Amit Chaudhary 8Amit Chaudhary 8
In Apex . I thing no. I am not sure but in VF page u can try below code
function RefreshPrimaryTab(id) 
        {
             if (sforce.console.isInConsole())
                  sforce.console.getFocusedPrimaryTabId(showTabId);
             else
                  window.top.location.href = '/' + id;
        }

 
SurekaSureka
Hi,

Yes.. it works in VF.. I want to know if there is something available in Apex.

Thanks
Garima Agarwal 45Garima Agarwal 45
Hi,

I am also facing this issue, please  help me  too refresh primary  tab.

Thanks