0

I have a VF page which needs to be displayed in the Console as subtab. The header and sidebar should not be displayed in the console. However I need the header and sidebar to show up if this page was accessed in Classic as tab. I’m using a custom button to call the page.

I don’t know how to determine if the page is being invoked in a console or differently so that the header and sidebar can be displayed accordingly?

VF to set subtab:

<apex:includeScript value="/support/console/26.0/integration.js"/> 
    <apex:includeScript value="/soap/ajax/26.0/connection.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("{!$objectType.ExpressOrder__c.label}");
    }; 
        </script>

My custom button with &isdtp=vw:

    {!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/28.0/integration.js")} 
var url = "/apex/VF013_Create_Express_Order?id={!Account.Id}&isdtp=vw"; 
if (sforce.console.isInConsole()) { 
srcUp(url); 
}else { 
window.open(url,'_self'); 
}

with &isdtp=vw

My button without &isdtp=vw:

{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/support/console/28.0/integration.js")}
var url = "/apex/VF013_Create_Express_Order?id={!Account.Id}";
if (sforce.console.isInConsole()) {
srcUp(url);
}else {
window.open(url,'_self');

withouth &isdtp=vw

0

I found this : Thanks to Nishant Singh Panwar

Code below :

{!REQUIRESCRIPT("/support/console/30.0/integration.js")}
if(typeof(srcUp) == 'function') //Checks that it is in console
{
var openSubtab = function(result){
sforce.console.openSubtab(result.id,'/apex/VF013_Create_Express_Order?id=
{!Account.Id}&inConsole=true', true, 'Subtab Name', null);
};
sforce.console.getEnclosingPrimaryTabId(openSubtab);
}
else{
window.parent.location.href=('/apex/VF013_Create_Express_Order?id=
{!Account.Id}&inConsole=false')
}

The job is done. I would have liked to use the 'var url'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.