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
Ryley HayesRyley Hayes 

Opening Console Tab from App Level Component

I have an App Level Consoler Component (the ones in the footer), which is just a basic VisualForce page with Javascript from the Console Integration Toolkit.

<apex:page>
<apex:includeScript value="/support/console/22.0/integration.js"/>
<script type="text/javascript">
function OpenPrimaryTab() {                              
               sforce.console.openPrimaryTab(null, 'http://www.salesforce.com', true, 'salesforce');
          }
</script>
<apex:form>
<apex:commandButton value="New Contact" onclick="OpenPrimaryTab()"/>
</apex:form>
</apex:page>

Clicking that button from the Console Component does nothing though.
Amit Chaudhary 8Amit Chaudhary 8
Hi Ryley,

Please check below blog. I hope that will help you:-

http://amitsalesforce.blogspot.in/search/label/Console

If you want to open the record in New Window then please try below code:-

Include JS in VF page
<apex:includeScript value="/support/console/26.0/integration.js"/>

Write below Java Script code in VF page
<script>

function openTab() 
{
 if (sforce.console.isInConsole())
  sforce.console.openPrimaryTab(undefined, '/003/e?isdtp=vw', true, 'New Contact');
 else
  window.top.location.href = '/003/e' ;
}

</script>

Then use below link to open new record .
<a href="#" onclick="openTab(); return false;">New Contact</a>

Please mark this as solution if this will help you.

Thanks,
Amit Chaudhary
amit.salesforce21@gmail.com
Ryley HayesRyley Hayes
Still doesn't work. Even when I preview the VF page outside the console, the "else" part of the function doesn't work either.
 
Amit Chaudhary 8Amit Chaudhary 8
Please try below code:-
<apex:page >
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script>
function openTab() 
{
 if (sforce.console.isInConsole())
  sforce.console.openPrimaryTab(undefined, '/003/e?isdtp=vw', true, 'New Contact');
 else
  window.top.location.href = '/003/e' ;
}
</script>
<apex:form >

<a href="#" onclick="openTab(); return false;">New Contact</a>
</apex:form>
</apex:page>

Please mark this as solution if this will help you.

Thanks
Amit Chaudhary