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
Alex.AcostaAlex.Acosta 

Running Service Cloud Console Javascript Within a Custom Button

I'm trying to use the same functions using javascript allowed on a visualforce page, but on a button.
IE: something alone these lines https://sites.secure.force.com/success/ideaView?id=08730000000YKxY

 

Problem is when I try running my javascript within my button... all browsers (Chrome, IE, and FireFox) throw exceptions with Salesforce javascript library....

 

Code is as follows:

{!REQUIRESCRIPT("/support/console/25.0/integration.js")}
if (sforce.console.isInConsole()) {
alert("in console");
} else {
alert("not in console");
}

 

Javascript Error:
Uncaught TypeError: Cannot read property 'Caller' of undefined integration.js:10
(anonymous function) integration.js:10
(anonymous function) integration.js:782


If you can please point me in the right direction of how to resolve this issue, i would greatly appreciate this.

Best Answer chosen by Admin (Salesforce Developers) 
Alex.AcostaAlex.Acosta

Answer was another JS library has to be included which gets included by VFpages automatcily when using the Console API.

 

code should now look like as follow to get the Cloud Console API to work within a button...

{!REQUIRESCRIPT("/xdomain/xdomain.js")} 
{!REQUIRESCRIPT("/support/console/25.0/integration.js")} 
if (sforce.console.isInConsole()) { 
alert("in console"); 
} else { 
alert("not in console"); 
}