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
5LINX IT Dept5LINX IT Dept 

custom button calls VF page to open in new subtab in console view

I need some help figuring out how to do the following. I have a custom button sitting on an account page layout. The custom button is currently set to open a VF page in a new window. that currently works fine. Our users use the service console view and they would like the VF page to open in a sub-tab instead of a new window. So after clicking the button the current account page (that the button is sitting on) should remain and a new sub-tab should open up showing the new VF page. They need to copy info from the acount page and paste it into the new VF page which is why they want it in a sub-tab so they can go back and forth between the two tabs. If you can help please provide example code. I am fairly new so the more explanation you can give the better :-) Thank you.
Peter YohannaPeter Yohanna
Hi,

I had a similar issue before for a visual force page that we needed to open as a new tab in service console or open normally in a standard app.

This article explains the approach to open a new tab from a custom button:
https://www.salesforce.com/blog/2013/05/the-service-cloud-console-working-with-buttons-and-links.html (https://www.salesforce.com/blog/2013/05/the-service-cloud-console-working-with-buttons-and-links.html" target="_blank)

However, to make this work for both Service Console and Standard app view, you'll need to add some JS as described in this link:
http://salesforce.stackexchange.com/questions/29041/javascript-execution-on-button-click-with-service-cloud-console (http://salesforce.stackexchange.com/questions/29041/javascript-execution-on-button-click-with-service-cloud-console" target="_blank)

Hope this helps.

Cheers,
Peter
5LINX IT Dept5LINX IT Dept
I was so close !! Thank you for that information. It clarified things for me and I got it to work! Yay!

I added this to my VF page right after the apex:page tag and right before the apex:form tag ...
<apex:includeScript value="/soap/ajax/26.0/connection.js"/>
    <apex:includeScript value="/support/console/26.0/integration.js"/>
    <script type="text/javascript">
        
        window.onload = function(){
           testOpenSubtab();
        };

        function testOpenSubtab() {
            //First find the ID of the primary tab to put the new subtab in
            sforce.console.getEnclosingPrimaryTabId(openSubtab);
        };

        var openSubtab = function openSubtab(result){
            var primaryTabId = result.id;
            sforce.console.setTabTitle('Add Rep Note');
        };
        
   </script>
and I added the following javascript to the custom button ...
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/28.0/integration.js")} 

var url = '/apex/Add_Rep_Notes?Id={!Account.Id}&isdtp=vw'; 

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


 
Nomios SupportNomios Support
Can you please share you whole page please?
I am trying to create a button that show only on certain conditions. That is done, but when onclick, I have a new window...i need a subtab :/ 

But I am a noob and I dont know how to use your code in onclick action

thanks