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
turbobuickturbobuick 

Open Subtab in Service Cloud Console - Help!

Hey all - 

 

I've searched google and the dev boards for a solution to this, but I'm struggling to figure out what is wrong with my visualforce code to open a subtab within the Service Cloud console. I've built a VisualForce table (apex:pageBlockTable) that displays a list of Cases and I'd like the "Case Number" column to be a link that opens that particular Case in a subtab. Anytime I try to click the hyperlink, it loads a 'URL No Longer Exists' error within the same frame (no subtab is opened). I'm trying to call the javascript subtab function as an onClick within the apex:outputlink tag - is this even possible?

 

Here's my current code - any help would be greatly appreciated!

 

<apex:page standardController="Case" extensions="CaseRecentCasesController">
    <apex:form >
    <apex:includeScript value="/support/console/22.0/integration.js"/>
    	<script type="text/javascript">
    		function parentTab() {
				//Get the ID of the primary tab
				sforce.console.getEnclosingPrimaryTabId(openSubtab);
				}
				
				var openSubtab = function openSubtab(result) {
					//Open subtab in primary tab
					var primaryTabId = result.id;
					sforce.console.openSubtab(primaryTabId, '/' + {!Case.id}, false, {!Case.CaseNumber});
					};
    	</script>
    <apex:inputHidden value="{!Case.Customer_Subscription__c}"/>
        <apex:pageBlock mode="maindetail">
            <apex:pageMessage escape="false" severity="info" strength="2" summary="The 10 most recent Cases are displayed for {!Case.Customer_Subscription__r.Name}." rendered="{!NOT(Case.Customer_Subscription__c = '')}"/>
            <apex:pageMessage severity="info" strength="2" summary="There are no recent Cases to display because a Customer Subscription is not associated with this Case. Please set one if applicable."  rendered="{!Case.Customer_Subscription__c = ''}" /> 
            <apex:outputPanel layout="block" style="overflow:auto; height:550px"  rendered="{!NOT(Case.Customer_Subscription__c = '')}">
                <apex:pageBlockTable value="{!RelatedCases}" var="rCase" style="overflow:auto">

                    <apex:column headerValue="Case Number">
                        <apex:outputlink onClick="openCaseSubtab()">{!rCase.CaseNumber}</apex:outputlink>
                    </apex:column>
                    <apex:column value="{!rCase.Subject}"/>
                    <apex:column value="{!rCase.Status}"/>
                    <apex:column value="{!rCase.Owner.Name}" headerValue="Case Owner"/>
                    <apex:column value="{!rCase.CreatedDate}"/>
                </apex:pageBlockTable>
                <br />
                <apex:outputlink target="_blank" value="/500?rlid=00N70000002JlrX&id={!Case.Customer_Subscription__r.Id}">View all Cases</apex:outputlink>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>


</apex:page>

 

digamber.prasaddigamber.prasad

Could you please share the URL built out from your code?

 

Happy to help you!

 

Regards,

Digamber Prasad

turbobuickturbobuick

Hi Digamber,

 

Are you asking for the URL that I would like to have opened as a subtab in the console view? If so, that URL would simply be a Case record. The record itself depends on the query that is returned from the controller class. In the code block below, I've marked the text in red for where I try to call the openSubtab method and then where I call it in the field of my pageBlockTable.

 

Below is the latest version of my code with any non-essential code removed. It's still not working as when I inspect the page, I'm receiving this error when trying to click the link and open the subtab: Uncaught ReferenceError: openCaseSubtab is not defined

 

<apex:page standardController="Case" extensions="CaseRecentCasesController">
    <apex:form >
    <apex:inputHidden value="{!Case.Customer_Subscription__c}"/>
    <apex:pageBlock mode="maindetail">
        <apex:outputPanel layout="block" style="overflow:auto; height:550px">
        	<apex:pageBlockTable value="{!RelatedCases}" var="rCase" style="overflow:auto">
            	
          	    <apex:includeScript value="/support/console/28.0/integration.js"/>
				<script type="text/javascript">
					function openCaseSubtab() {
							sforce.console.getEnclosingPrimaryTabId(openSubtab);
						}
						
						var openSubtab = function openSubtab(result) {
							sforce.console.openSubtab(result.id, '/'+'{!rCase.id}'+'?isdtp=vw',false);
						};
						
						var previousOnload = window.onload;
							window.onload = function() {
							if(previousOnload) {
								previousOnload();
							}
							
							openCaseSubtab();
						}
				</script>
            	
            	<apex:column headerValue="Case Number">
                	<apex:outputlink onClick="openCaseSubtab()">{!rCase.CaseNumber}</apex:outputlink>
                </apex:column>
                <apex:column value="{!rCase.Subject}"/>
                <apex:column value="{!rCase.Status}"/>
                <apex:column value="{!rCase.Owner.Name}" headerValue="Case Owner"/>
                <apex:column value="{!rCase.CreatedDate}"/>
			</apex:pageBlockTable>
                <br />
                <apex:outputlink target="_blank" value="/500?rlid=00N70000002JlrX&id={!Case.Customer_Subscription__r.Id}">View all Cases</apex:outputlink>
        </apex:outputPanel>
    </apex:pageBlock>
    </apex:form>


</apex:page>

 

 

digamber.prasaddigamber.prasad

Hi,

 

Now, I can understand what you want to achieve. Is it possible to create a custom field, if yes please create a custom formula field with API Name Case_URL__c, formula of field will be like:-

 

HYPERLINK( LEFT($Api.Partner_Server_URL_280, FIND( '/services', $Api.Partner_Server_URL_280))  & Id , CaseNumber ).

 

This will create a formula field, whose text will be Case Number. However, as soon as you will click on it it will open in new tab within console

 

<apex:page standardController="Case" extensions="CaseRecentCasesController">
    <apex:form >
    <apex:inputHidden value="{!Case.Customer_Subscription__c}"/>
    <apex:pageBlock mode="maindetail">
        <apex:outputPanel layout="block" style="overflow:auto; height:550px">
        	<apex:pageBlockTable value="{!RelatedCases}" var="rCase" style="overflow:auto">
            	
          	    
            	
            	<apex:column value="{!rCase.Case_URL__c}"/>
<apex:column value="{!rCase.Subject}"/> <apex:column value="{!rCase.Status}"/> <apex:column value="{!rCase.Owner.Name}" headerValue="Case Owner"/> <apex:column value="{!rCase.CreatedDate}"/> </apex:pageBlockTable> <br /> <apex:outputlink target="_blank" value="/500?rlid=00N70000002JlrX&id={!Case.Customer_Subscription__r.Id}">View all Cases</apex:outputlink> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>

 

Please let me know if it doesn't work for you.

 

Happy to help you!

 

Regards,

Digamber Prasad

 

 

 

 

turbobuickturbobuick

Hi Digamber,

 

Thanks for your response. I'm confused as to why using $API.Partner_Server_URL_280 to build a hyperlink would force the link to open in a subtab within the Service Cloud console.

 

Is it not possible to use the OpenSubtab() method that is available in the integration toolkit?

 

Thanks,

Joe

digamber.prasaddigamber.prasad

Hi,

 

Could you please give it a try and let me know if it works for you or not. In my case it worked properly. If not in your case, then we can discuss it further.

 

Happy to help you!

 

Regards,

Digamber Prasad

The_London_ScottThe_London_Scott
I'm hitting much the same problem and it should not be necessary to define a custom field to open a URL; that seems a hacky solution.  Like turbobuick, I am unclear whether I can call a Service Cloud Console Integration Toolkit method from the <apex:outputLink> tag or not. 

The discussion here (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000998qIAA) suggests that outputLink uses the srcUp method automatically, producing this error. A code sample which claims to solve the problem is here (http://salesforce.stackexchange.com/questions/27809/service-cloud-console-subtab-lookup-field-and-output-link).
turbobuickturbobuick
Hello London Scott -

I forgot to update this discussion after we solved this issue internally - it is possible to call the Service Cloud Console Integration Toolkit method from within an <apex:outputLink> tag though it wasn't immediately clear how to implement this functionality. You cannot use a defined link format or the srcUp method directly in the tag - you must define the function (as in the second post you linked to) using the console toolkit. Below are the two things that need to be implemented and in bold, the implementation from the code we developed.
  1. You must define a javascript function within your VisualForce page that calls the open subtab function. Depending on what you need to accomplish, the function may need to take an argument (such as an ID if you would like a Lookup field to be opened in a subtab) or you can manually define the address if it's a specific URL (google.com).
  2. Within the Apex tag for the custom field, you need to use onClick="function(argument)" href=javascript:;" so your function is executed

<apex:page standardController="Case" extensions="RecentCasesExtension">

<apex:includeScript value="/support/console/29.0/integration.js"/>
<script type="text/javascript">
 
    // Opens a subtab when a related Case Number is clicked
  function openCaseSubtab(caseId) {
   // Check if user is in the Console, otherwise open as a regular URL
      if (sforce.console.isInConsole()) {
    sforce.console.getEnclosingPrimaryTabId(function(result){
     sforce.console.openSubtab(result.id, '/' + caseId, true, '', null);

    });
   } else {
    window.open('/' + caseId);
    }
  };
 </script>

    <apex:form >
    <apex:inputHidden value="{!Case.Customer_Subscription__c}"/>
    <apex:pageBlock mode="maindetail">
     <apex:pageMessage escape="false" severity="info" strength="2" summary="The 10 most recent Cases are displayed for {!Case.Customer_Subscription__r.Name}." rendered="{!NOT(Case.Customer_Subscription__c = '')}"/>
        <apex:pageMessage severity="info" strength="2" summary="There are no recent Cases to display because a Customer Subscription is not associated with this Case. Please set one if applicable."  rendered="{!Case.Customer_Subscription__c = ''}" />
        <apex:outputPanel layout="block" style="overflow:auto; height:600px"  rendered="{!NOT(Case.Customer_Subscription__c = '')}">
         <apex:pageBlockTable value="{!RelatedCases}" var="rCase">
             <apex:column headerValue="Case Number">
                 <!-- Use onClick JS to invoke the subtab function above passing in the Case ID from the table -->
                  <a onClick="openCaseSubtab('{!rCase.Id}')" href="javascript:;">{!rCase.CaseNumber}</a>

                </apex:column>
                <apex:column value="{!rCase.Subject}"/>
                <apex:column value="{!rCase.Status}"/>
                <apex:column value="{!rCase.Owner.Name}" headerValue="Case Owner"/>
                <apex:column value="{!rCase.CreatedDate}"/>
   </apex:pageBlockTable>

Snehal Phatangare 1Snehal Phatangare 1
Thanks turbobuick!

This is exactly what i required!