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
naveen reddy 19naveen reddy 19 

How to open a record in console from custom console component

Hi,

 I had to create a custom console component. Which will display some cases based on some criteria.
Whenever a user clicks case record it should open in console. Can you please help in how to open record in console from custom console components.

The following is the sample visualforce code.
 
<apex:page standardController="Case" extensions="caseCon" sidebar="false"  >
<apex:form id="frm" >
 <apex:pageBlock title="Pnned Cases">
        <apex:pageBlockTable value="{!pinnedCases}" var="cse" id="pBlk">
            <apex:column headerValue="Case Number" >
              <apex:outputLink > {!cse.CaseNumber}</apex:outputLink>    
            </apex:column>           
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

User-added image

Thanks,
Naveen.
Aman MalikAman Malik
Hi Naveen,
Hopefully below code will work for you:
<apex:page standardController="Case">
<apex:form id="frm" >
    <apex:includeScript value="/support/console/41.0/integration.js"/>
    <script type="text/javascript">
        var currentCaseId = '';
        function testOpenPrimaryTab(caseId) {
            if(caseId){
                currentCaseId = caseId;
                sforce.console.getFocusedPrimaryTabId(showTabId);
            }
        }
        var showTabId = function showTabId(result) {
            //Display the tab ID
            alert('Tab ID: ' + result.id);   
            sforce.console.openSubtab(result.id, '/' + currentCaseId, true, 'MyCase Detail', null, openSuccess, 'tab'); 
        };
        var openSuccess = function openSuccess(result) {
            //Report whether opening the new tab was successful
            if (result.success == true) {
                alert('Primary tab successfully opened');
            } else {
                alert('Primary tab cannot be opened');
            }
        };
        
    </script>
    <apex:pageBlock title="Pnned Cases">
        <apex:pageBlockTable value="{!pinnedCases}" var="cse" id="pBlk">
            <apex:column headerValue="Case Number" >
              <apex:outputLink onclick="testOpenPrimaryTab('{!cse.Id}');return false"> {!cse.CaseNumber}</apex:outputLink>    
            </apex:column>           
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>
Kindly let me know in case any query.

Please mark the answer as best if it helps.

Thanks
 
naveen reddy 19naveen reddy 19
Hi Aman,

Thanks for response and help.

I tried using above code it resulting to following alerts but not opening the record.

User-added image

User-added image

 
Aman MalikAman Malik
Hi Naveen,
I thought your component is embeded on the right side of detail page. It seems your component can open in any view(list or detail). So the above mentioned code would not work for you.
You need to explore below service console developer guide:
https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_methods_tabs.htm
Through above guide you can do whatever you want.

Thanks,
Aman