[SalesForce] Javascript Execution on Button Click with Service Cloud Console

I've always setup buttons to execute javascript on click so I can properly render the new page/tab based on where the user is at (cloud console or standard view). Today upon testing this exact bit of code, I'm hitting the notorious "sforce.console is null or not an object" when using Internet Explorer. (After some research this is affecting multiple versions of IE)

{!REQUIRESCRIPT("/xdomain/xdomain.js")} 
{!REQUIRESCRIPT("/support/console/28.0/integration.js")} 

var url = '/apex/AccountActiveReservations?Id={!Account.Id}'; 

if (sforce.console.isInConsole()) { 
srcUp(url); 
} else { 
window.open(url,'_blank');
}

Am I doing something wrong here?

PS I've already tried doing the following: (as suggested in the ideas exchange)

{!REQUIRESCRIPT("/xdomain/xdomain.js")} 
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/support/console/28.0/integration.js")} 

var url = '/apex/AccountActiveReservations?Id={!Account.Id}'; 

if (sforce.console.isInConsole()) { 
srcUp(url); 
} else { 
window.open(url,'_blank');
}

Update:
I have dug deeper and pulled out an existing button which works on the Campaign Member Sobject just fine. Here's the meta data

<webLinks>
    <fullName>EditOSAccount</fullName>
    <availability>online</availability>
    <displayType>button</displayType>
    <linkType>javascript</linkType>
    <masterLabel>New Edit OS Account</masterLabel>
    <openType>onClickJavaScript</openType>
    <protected>false</protected>
    <url>{!REQUIRESCRIPT(&quot;/xdomain/xdomain.js&quot;)} 
    {!REQUIRESCRIPT(&quot;/support/console/25.0/integration.js&quot;)} 

    var url = &apos;/apex/NewOwnerExperienceWizard?MemberId={!CampaignMember.Id}&apos;; 

    if (sforce.console.isInConsole()) { 
    srcUp(url); 
    } else { 
    window.location.href = url; 
    }</url>
</webLinks>

Here's the one on Account (Person Account) which is causing me issues:

<webLinks>
        <fullName>Active_Reservations</fullName>
        <availability>online</availability>
        <displayType>button</displayType>
        <linkType>javascript</linkType>
        <masterLabel>Active Reservations</masterLabel>
        <openType>onClickJavaScript</openType>
        <protected>false</protected>
        <url>{!REQUIRESCRIPT(&quot;/xdomain/xdomain.js&quot;)} 
    {!REQUIRESCRIPT(&quot;/support/console/25.0/integration.js&quot;)} 

    var url = &apos;/apex/AccountActiveReservations?Id={!Account.Id}&apos;; 

    if (sforce.console.isInConsole()) { 
    srcUp(url); 
    } else { 
    window.open(url,&apos;_blank&apos;);
    }</url>
</webLinks>

I believe this is a Salesforce bug and will be creating a ticket. If you guys or gals see something that I can try, please let me know

Update:

3/14/2014

Salesforce has finally picked up the case after a almost 2 weeks. Tier 2 support has been able to duplicate the issue within my FULL sandbox environment. He will be testing within his and let me know what results he comes up with.

3/17/2014

Looks like it's been either escalated to someone with more experience in tier 2 or it went to tier 3. Waiting back to hear from support.

3/19/2014

Salesforce Tier 3 closed the case on me stating this was development and that I need to have premium support to continue.

7/16/2014

Solution posted below.

Best Answer

1) You have missed one of the RequiredScripts :

<apex:includeScript value="/soap/ajax/26.0/connection.js"/> 

2) check this link it says how to load your JS in a specific order:

https://success.salesforce.com/issues_view?id=a1p30000000SYcEAAW

Workaround

- Load the scripts in a different order: 

<apex:includeScript value="/soap/ajax/26.0/connection.js"/>  
<apex:includeScript value="/support/console/26.0/integration.js"/>

enter image description here

Related Topic