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
ClaiborneClaiborne 

Launching a Visual Force Page in the Service Cloud Console

From the Case object, we have a custom button that creates an RMA with case and account information filled in and then opens the new RMA record. It works fine in the normal salesforce.com.

 

In the Service Cloud Console, we have Accounts, Cases, and RMA's. If we create new Cases or new RMA's from the Account, the new records get create in new subtabs to the account.

 

But if we launch our CaseToRMA page from the case in a Service Cloud Console subtab, it results in a whole new instance of saleforce.com running in the original case tab. What we want is for the new RMA to open in a new subtab under the account and to leave the case open.

 

CasetoRMA class

 

public class CaseToRMA {
    public Case c {get; set;}
    public RMA__c rma {get; set;}
public CaseToRMA () { c = [ select c.Id, c.CaseNumber, c.Account.ShippingCountry, c.Account.ShippingPostalCode, c.Account.ShippingState, c.Account.ShippingCity, c.Account.ShippingStreet, c.Account.Name, c.AccountId from Case c where id = : apexPages.currentPage().getParameters().get('id')];
List<Settings__c> cs = [ select RMA_Warehouse__c from Settings__c]; RMA__c rma = new RMA__c( ZipPostalCode__c = c.Account.ShippingPostalCode, Warehouse__c = (cs.size() > 0) ? cs[0].RMA_Warehouse__c : null, Street__c = c.Account.ShippingStreet, StreetTextArea__c = c.Account.ShippingStreet, RMADate__c = system.today(), Country__c = c.Account.ShippingCountry, City__c = c.Account.ShippingCity, Case__c = c.Id, Account__c = c.AccountId, AccountName__c = c.Account.Name, Reference__c = c.CaseNumber); }

public PageReference NewRMA() {
insert rma;
return new PageReference('/' + rma.id);
}

 

 

 

 VisualForce Page

<!-- Old way -->
<apex:page controller="CaseToRMA" action="{!newRMA}" >
<!-- Attempt at opening in a new tab
<apex:page controller="CaseToRMA" action="{!newRMA}" >
    <apex:includeScript value="/support/console/20.0/integration.js"/>
    <script type="text/javascript">
        function init() {
                //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        }
        var openSubtab = function openSubtab(result) {
                //Now that we've got the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , '/' + rma.id, false,
                rma.Name, null, null);
        };
    </script>
    <body onLoad="Init()"/>
-->
</apex:page>

 If someone has a working example of this, it would be great.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
MayTheForceBeWithYouMayTheForceBeWithYou

I recently was dealing with a similar issue and eventually had to reach out to Salesforce support for a resolution. Here is a snippet of my original code:

<apex:includeScript value="/support/console/26.0/integration.js"/>
<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
<script type="text/javascript">  
  function openNewSubtab() {
      //First find the ID of the current primary tab
      sforce.console.getFocusedPrimaryTabId(getCaseId);
  }
  ....     
</script>

There was obviously more javascript code, but it was not relevant to the problem at hand. In the end, all that needed to be done was declare the ajax toolkit BEFORE the service cloud console toolkit as seen below:

 

<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">  
  function openNewSubtab() {
      //First find the ID of the current primary tab
      sforce.console.getFocusedPrimaryTabId(getCaseId);
  }
  ....
</script>   

Apparently IE8 has some issue that requires the ajax toolkit to be declared first, otherwise you will get the 'sforce.console is null or not an object' error.

 

Hope this helps!

All Answers

rpotterflrpotterfl

Did you ever resolve this issue?  We are having the same problem.

ClaiborneClaiborne

No. I ended up abandoning my VisualForce page. We definitely need an example with some sample code that works.

rpotterflrpotterfl

You may want to see this link:

http://success.salesforce.com/ideaView?id=08730000000XhSBAA0&c=09a30000000D9xoAAC

 

Or contact the author:

gvasudev@salesforce.com

 

We have had some buggy behavior with Service Console Tabs.

StephNWStephNW

Hi,

 

I also had this problem (a whole new instance of saleforce.com running within the primary tab). I found that setting the showHeader flag to false solved it for me:

apex:page showHeader="false" sidebar="false"
ClaiborneClaiborne

This works to allow the page to display within the current tab.

 

But there are other problems. For instance, in my process, I launch a VF page from an account. Setting the ShowHeader=false and sidebar=false allows the VF page to display in the tab. But I have a button on the VF page that takes me back to the account. But this opens a full account page - with headers and sidebar - in the tab.

 

Is there a way to come back to the tab?

 

Or is there a way to launch the VF page as a new tab?

 

And, so this all works in both the service console AND regular stuff, is there a way for the VF page to sense it is being rendered inside a service console tab or not.

rpotterflrpotterfl

I believe that if you add the following to the end of the link, it will take out the header and sidebar:  "&isdtp=vw"

Juan SpagnoliJuan Spagnoli

Try using "&inline=1" in the URI. 

 

For opening a new tab with a custom button we uses: 

 

navigateToUrl('/apex/theCasePage?id={!Case.Id}&inline=1');

 

 

For opening a new tab from a VF:

 

// global vars

var url2open = '';

var tabTitle = '';

 

// open URLs in new tabs - CONSOLE TOOLKIT REQUIRED

function openUrl(p_url2open, p_tabTitle) {

      try{

            window.parent.openUrl(p_url2open, p_tabTitle);

      }catch(e){

            // load global variables

            url2open = p_url2open;

            tabTitle = p_tabTitle;

            // go

            sforce.console.getEnclosingPrimaryTabId(openurl_subtab);

      }

};

 

var openurl_subtab = function(result) {

      var primaryTabId = result.id;

      // open tabs

      force.console.openSubtab(primaryTabId, url2open, true, tabTitle, null, null);

}

 

The idea is to have this functions as an static resource "js", and include it in your pages.

 

IMPORTANT: Be careful if your uses a visualforce inside another vf, for example using <apex:iframe/>. The services console has one level of indirection between domains, so if you try to use console toolkit inside the iframe, you will get a javascript error because cross-site restrictions. To avoid the issue you have to call any function using the parent page, that's why we put a try-catch block in our function. 

Same happends if you override a view's link and use a custom page with a <apex:detail>, for example for cases. You will have a LOT of problems, because in that case the level of indirection is two. :smileysad:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

skausskaus

I am trying to open an additional subtab while opening a case. I wrote a visualforce page with javascript on it and embedded on the case page layout.

I actually took help of sample code avaiable in a forum.

 

It works perfectly fine on firefox but I run into issues in IE.

 

I am using IE 8. Service toolkit provides to use sforce.cosnole.<methodname> methods for console customization. I am always getting error :

'sforce.console' is nul or not an object.

 

Did any of you got this problem ? Any clue what's the reason and how can I get around this one ?

var openSubtabTimer = null;    

function openFinProfileSubtab() {

        sforce.connection.sessionId = '{!$Api.Session_ID}';    

     var openSubtab = function(result) { 
if (sforce.console.isInConsole()) { 
        alert('console');
       sforce.console.openSubtab(result.id,'https://cs12.salesforce.com/a06V0000000BE6k',false,'Financial profile');           
       clearTimeout(openSubtabTimer);
      }
    };
        
      // Get the enclosing primary tab id. The openSubtab method is set as the callback
    sforce.console.getEnclosingPrimaryTabId(openSubtab);
    
    }
  
    var previousOnload = window.onload;        
    window.onload = function() {
    sforce.connection.sessionId = '{!$Api.Session_ID}';
    if ( previousOnload) {         
            previousOnload();
        }        
        
   
    openSubtabTimer = setTimeout('openFinProfileSubtab()', '100'); 
    
    
    }

 

sfdcAnonsfdcAnon

Hi folks,

 

The Console is usually not aware of the content being opened in it. If you would like to open subtabs or primary tabs in "Console" mode, ie without the header and sidebar, the Console must be passed a param.

 

More can be learned in this article - http://success.salesforce.com/ideaView?id=08730000000Xp3uAAC .Note the use of the isdtp param in /home/home.jsp?isdtp=vw

 

A complete list of Console blogs can be found here -

http://wiki.developerforce.com/page/DevelopingWithServiceAndSupport#The_Service_Cloud_Console

BilluBillu

Hi Skaus , 

     Did you finad any solution to this problem ??? 
     I am getting the same problem .

 

    Please do post the solution if you have  

MayTheForceBeWithYouMayTheForceBeWithYou

I recently was dealing with a similar issue and eventually had to reach out to Salesforce support for a resolution. Here is a snippet of my original code:

<apex:includeScript value="/support/console/26.0/integration.js"/>
<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
<script type="text/javascript">  
  function openNewSubtab() {
      //First find the ID of the current primary tab
      sforce.console.getFocusedPrimaryTabId(getCaseId);
  }
  ....     
</script>

There was obviously more javascript code, but it was not relevant to the problem at hand. In the end, all that needed to be done was declare the ajax toolkit BEFORE the service cloud console toolkit as seen below:

 

<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">  
  function openNewSubtab() {
      //First find the ID of the current primary tab
      sforce.console.getFocusedPrimaryTabId(getCaseId);
  }
  ....
</script>   

Apparently IE8 has some issue that requires the ajax toolkit to be declared first, otherwise you will get the 'sforce.console is null or not an object' error.

 

Hope this helps!

This was selected as the best answer
sfdcAnonsfdcAnon

Thanks for updating this post MayTheForceBeWithYou.

TaoTao

 

 Thank you MayTheForceBeWithYou. It works!