0

Classic console. The visualforce page renders a single button that passes an valueto another visualforce page to launch an existing process that the client does not want to be modified. This code works, but I can only get it to work by opening a new browser tab. openPrimaryTab() methods arent working. I think because the visualforce page that renders the button is inside an iframe on the page layout.

<apex:page standardController="orders__x">
    <apex:includeScript value="/support/console/44.0/integration.js"/>
    <script type="text/javascript">
    function startWarrantyClaim(){

        window.open('/apex/warrantyclaim?orderNum={!orders__x.DEL_DOC_NUM__c}', '_blank');
        //window.open('/apex/warrantyclaim?orderNum='+{!orders__x.DEL_DOC_NUM__c},'_blank');
        //sforce.console.openSubTab(null, 'http://www.salesforce.com', false,'salesforce', openSuccess, 'salesforceTab');
        // window.location('http://www.salesforce.com');
    }
    </script>

    <apex:form>
        <apex:commandButton value="New Warranty Claim - Order" onclick="startWarrantyClaim()"/>
    </apex:form>

</apex:page>

1 Answer 1

1

You're right about the console integration methods not working because they're being called from inside an iFrame. Is there any reason the button needs to be in a visualforce page embedded in the record detail page? If you could use a plain o'l js custom button, you could make it work using something like this:

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

// See whether we're in the console
if(typeof(srcUp) == 'function') { 
    var openSubtab = function(result){ 
        sforce.console.openSubTab(null, '/apex/warrantyclaim?orderNum=' {!orders__x.DEL_DOC_NUM__c}, false,'salesforce', openSuccess, 'salesforceTab'); 
    }; 
    sforce.console.getEnclosingPrimaryTabId(openSubtab); 

} else { 
    window.parent.location.href=('/apex/warrantyclaim?orderNum='+{!orders__x.DEL_DOC_NUM__c});
}
2
  • The reason i cant go this route is because the external object data is not available to javascript buttons. Thanks for the recommendation. I will double check this.
    – Allen Mann
    Commented Oct 5, 2018 at 12:19
  • Ooh -- interesting challenge. I didn't notice that orders was an external object at first. So can you say more about that? What's the business workflow? Maybe there's a work-around. Commented Oct 5, 2018 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .