Tuesday 3 March 2015

How to open a new record inside a console in SubTab by inline visual force page

Include JS in VF page

<apex:includeScript value="/support/console/26.0/integration.js"/>

Write below Java Script code in VF page


 var preRecordId;
        function testOpenSubtab(id, name) 
            preRecordId= id;
            //First find the ID of the primary tab to put the new subtab in


             if (sforce.console.isInConsole())
              window.top.location.href = '/' + id;
        var openSubtab = function openSubtab(result) 
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            sforce.console.openSubtab(primaryTabId , '/'+preRecordId , true, 
                preRecordId , null , openSuccess, 'salesforceSubtab');
        var openSuccess = function openSuccess(result) 
            //Report whether we succeeded in opening the subtab
                if (result.success == true) 
                    alert('subtab successfully opened');
                    alert('subtab cannot be opened');

Then use below link to open new record .

 <a href="#" onclick="testOpenSubtab('{!Obj.id}', '{!Obj.id}');return false">{!Obj.customKey}</a>

No comments:

Post a Comment