+ Start a Discussion
CharlieLangCharlieLang 

Service cloud and tabs

Hi,

I've got a VF page in my service cloud that has a number of links in it. 

 

Can someone help me - when i click on the links they just stay in the same tab, is there a way that when the link is clicked it brings up the item in a new tab?

 

this is the current code i use on the link

 

<apex:outputLink value="/{!contact.id}">{!contact.account.name}</apex:outputLink>

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I think you'll need to put that into an onclick rather than as the value of the outputlink.  Otherwise that will be expected to be a URL type of thing.

All Answers

bob_buzzardbob_buzzard

If you specify a target attribute of _blank, it will open in a new window or tab depending on how the browser is configured.

 

E.g.:

 

<apex:outputLink value="/{!contact.id}" target="_blank">{!contact.account.name}</apex:outputLink>

 

CharlieLangCharlieLang

That would open a new tab or window in the browser?

 

i want to create a new tab within the service cloud page

bob_buzzardbob_buzzard

Are you talking about the service cloud console?

CharlieLangCharlieLang

Yes

 

At the moment i have 4 lots of these for columns

 

<apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="firstName" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!contact.id}">{!contact.firstName}</apex:outputLink>
            </apex:column>

I would like it that when you click on one of the links the contact comes up in another primary tab 

bob_buzzardbob_buzzard

Service cloud console is a different kettle of fish.  You have to use the API to do that kind of thing, but this means that your page may have to be aware whether its working in the console or as part of a regular view.

 

The API is at:

 

http://www.salesforce.com/us/developer/docs/api_console/index.htm

 

and the function that you'll probably want is:

 

http://www.salesforce.com/us/developer/docs/api_console/index_Left.htm#CSHID=sforce_api_console_openprimarytab.htm|StartTopic=Content%2Fsforce_api_console_openprimarytab.htm|SkinName=webhelp

CharlieLangCharlieLang

**bleep** it. why cant it be simple!

CharlieLangCharlieLang

anyone have a clue about this?

 

i am trying something along the lines of 

 

<apex:outputLink value=apex:sforce.console.openPrimaryTab(Null, "/{!contact.id}", true, {!contact.lastName})>{!contact.lastName}</apex:outputLink>

 

which isnt working successfully :-(

bob_buzzardbob_buzzard

I think you'll need to put that into an onclick rather than as the value of the outputlink.  Otherwise that will be expected to be a URL type of thing.

This was selected as the best answer
CharlieLangCharlieLang

ok, so i think i'm making some progress with this (creating a new tab in the service cloud from a dynamically built list)

 

I can now get a tab to appear but for some reason its linking to the same contact all the time so i think somewhere along the line somethings now working right?

 

Can anyone give me any pointers? It would be much appreciated.

 

When i've finished this i'll put the share all the code ;-)

 

 

<apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Employee ID" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Employee_Number__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
          </apex:facet>
          
              <A HREF="#" onClick="testOpenPrimaryTab();return false">{!contact.Employee_Number__c}</A> 

                <script type="text/javascript">
                    function testOpenPrimaryTab() {
                        //Open a new primary tab with the customer details in it
                        sforce.console.openPrimaryTab(null, '/{!contact.id}', true, '{!contact.firstName} {!contact.lastname}', openSuccess, 'CustomerTab');
                    }
        
                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:column>

 

PalakPalak

Hi,

 

I have created a custom tab with visualforce content, and using it in navigation tab of service console.

 

When I am click on this tab, visualofrce loads, and if I am dropping the navigation drop down, then clicking anywhere outside the drop down menu does not closes the navigation drop down list.

 

Could you please help me?

 

Thanks & Regards

Palak Agarwal

DevelopersDevelopers

Hi Bob,

 

I am facing some issues to open the case in a new subtab. We used the below code. Here, we are implementing the below things:

 

1. Create a new case when the user clicks on the custom button called on Remake.

2. Then, remake() is called to send the remake case details to SAP ECC.

 

I used the below code to open the created case in a new subtab after the execution of these two methods.

 

But, i dont know, the created new case is not rendering on VF page and new subtab is not opening.

 

I pasted the code below. Please check and support me to fix this issue.

 

VF Page:

<apex:page standardController="Orders__c" extensions="Order_Header_Component_Controller">
    <apex:form >
        <apex:includeScript value="/support/console/25.0/integration.js"/>
        <script>
            var button;
            function disableButton()
            {
                button.disabled = true;
            }
            
            function changeButton()
            {
                alert("Change has been sent to ECC.");
            }
        </script>
        <script> //declare js vars
            var newCaseId;
        </script>
        <apex:outputPanel id="jsVarsPanel">
            <script> //set js vars to controller properties
                newCaseId='{!insertedNewCaseId}';
            </script>
        </apex:outputPanel>
        <script type="text/javascript">
            function openNewCaseInSubTab() {
                sforce.console.getEnclosingPrimaryTabId(openSubtab);
            }
            var openSubtab = function openSubtab(result) {
                var primaryTabId = result.id;
                alert(newCaseId);
                var URLValue = '/'+newCaseId+'?isdtp=vw';
                alert("Value of the URLValue......"+URLValue);
                sforce.console.openSubtab(primaryTabId,URLValue, true,'New Case', null, openSuccess, 'NewCaseSubtab');
            };
            var openSuccess = function openSuccess(result) {
                if (result.success == true) {
                    button.disabled=false;
                    alert('subtab successfully opened');
                } else {
                    alert('subtab cannot be opened');
                }
            };
        </script>
        <apex:pageBlock mode="maindetail">
            <apex:pagemessages />
            <apex:pageBlockButtons location="top" >
                <apex:actionFunction name="remake" action="{!remake}"/>
                <apex:commandButton action="{!insertCase}" oncomplete="remake(); openNewCaseInSubTab(); return false;" value="Remake" rerender="redirectPanel,jsVarsPanel" id="remake" onclick="disableButton();" rendered="{!showButtons}"/>
                <script type="text/javascript">
                    button = document.getElementById('{!$Component.remake}');
                </script>
                <apex:commandButton action="{!newCase}" oncomplete="openNewCaseInSubTab(); return false;" value="New Case" rerender="redirectPanel,jsVarsPanel" id="newCase" onclick="disableButton();"/>
                <script type="text/javascript">
                    button = document.getElementById('{!$Component.newCase}');
                </script>
        </apex:pageBlockButtons>            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Methods:-
public void insertCase()
    {       
        List<Orders__c> ol = [SELECT Id FROM Orders__c WHERE Order_Num__c =: o.Order_Num__c limit 1];

        newCase = new Case(OwnerId = UserInfo.getUserId(),
                                Subject = 'Remake: ' + o.Side_Marks_Txt__c,
                                Description = 'Case for Order # ' + o.Order_Num__c,
                                Reference__c = o.Order_Num__c,
                                Original_Order__c = ol[0].Id,
                                AccountId = o.AccountID__c,
                                Status = 'In Process',
                                Origin = 'Phone',
                                Reason = 'Product',
                                Type = 'Challenge',
                                Case_Reason_Details__c = 'Remake Processed',
                                RecordTypeId ='012E0000000LbAy');
                                
        AssignmentRule ar = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
        Database.DMLOptions dmlOpts = new Database.DMLOptions();
        dmlOpts.assignmentRuleHeader.assignmentRuleId= ar.id;
        newCase.setOptions(dmlOpts);
        
        insert newCase;
        
        insertedCaseId = newCase.Id;        
        
    }
    public void remake()
    {     
        newCase = [SELECT CaseNumber, Id FROM Case WHERE Id =: insertedCaseId limit 1];
        system.debug('Value of the case id in remake method.....'+newCase.Id);
        
        //Only allow a remake on an original order   
        system.debug('Value of the Order Type Code in remake....'+o.Order_Type_Cd__c);   
        if (o.Order_Type_Cd__c != 'ZOR')
        {
                ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Create with reference to the original order only.  Order Type Code : ' + o.Order_Type_Cd__c);
            ApexPages.addMessage(errormsg);
            isRedirecting = false;
            delete newCase;
            //return null;
        }
        if (this.AuthorizationExists == false)
        {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'Custom setting configuration is not complete.  Please contact your system administrator');
            ApexPages.addMessage(errormsg);
            delete newCase;
           //return null;
        }        
        try {
            
            isRedirecting = true;
            String userId = UserInfo.getUserId();
            
            User currentUser = [SELECT Email FROM User WHERE Id =: userId limit 1];
            System.debug('*** currentUser ***: ' + currentUser);
            
            SapSoapOrderRemakeRepair.Z7ttReturn call;
            
            Account a = [SELECT Id, Account__c, Sales_Organization__c FROM Account WHERE Id = :o.AccountID__c LIMIT 1];
            //TODO: Include call to create case and retrieve Case Id from call
            SapSoapOrderRemakeRepair.zwsb_zsf_order_create soapCall = new SapSoapOrderRemakeRepair.zwsb_zsf_order_create();
            SapSoapOrderRemakeRepair.ZvtHdrFields orderRemake = new SapSoapOrderRemakeRepair.ZvtHdrFields();
            
            orderRemake.Vbeln = o.Order_Num__c;
            orderRemake.Tcode = 'VA01';
            orderRemake.Auart = 'ZQC';
            orderRemake.Augru = 'REM';
            orderRemake.SmtpAddr = currentUser.Email.removeEnd('.full');
            orderRemake.Vkorg = a.Sales_Organization__c;
            orderRemake.Kunnr = a.Account__c;
            orderRemake.CaseNum = newCase.Id;
            orderRemake.ActCaseNumber = newCase.CaseNumber;
            
            System.debug('*** SmtpAddr ***: ' + orderRemake.SmtpAddr);
            System.debug('*** CaseNum ***: ' + orderRemake.CaseNum);
            
            //TODO: Wrap the webservice call in a try catch block
            //TODO: Once a return message and status is included modifiy to parse results
            try {
                soapCall.inputHttpHeaders_x = new Map<String, String>();
                soapCall.inputHttpHeaders_x.put('Authorization', this.Authorization);
                soapCall.clientCertName_x = 'SapPiCert';
                
                System.debug('*** Calling REMAKE ***: ');
                call = soapCall.ZsfOrderCreate(orderRemake);
            } catch (System.Typeexception te) {
                soapCall = new SapSoapOrderRemakeRepair.zwsb_zsf_order_create();
                SapSoapOrderRemakeRepair.Z7ttReturn temp = new SapSoapOrderRemakeRepair.Z7ttReturn();
                temp.item = new SapSoapOrderRemakeRepair.Z7strBapiret2[]{};
                //SapSoapOrderRemakeRepair.ZvtHdrFields orderRemake = new SapSoapOrderRemakeRepair.ZvtHdrFields();
                SapSoapOrderRemakeRepair.Z7strBapiret2 mimicResponse = new SapSoapOrderRemakeRepair.Z7strBapiret2();
                mimicResponse.Message = 'DB entries saved';
                temp.item.add(mimicResponse);
            }
            
            
            /**************************************************************************
             * Notes       : Checking the return message from the webservice call to
             *               SAP to verify that the webservice call returns a
             *               "success" message.
             *************************************************************************/
            if (call.item[0].Message != 'DB entries saved')
            {
                System.debug('*** testing received message ***');
                ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.FATAL, soapCall.ZsfOrderCreate(orderRemake).item[0].Message + ' : User = ' + orderRemake.SmtpAddr);
                ApexPages.addMessage(errormsg);
                isRedirecting = false;
                delete newCase;
                //return null;
            }
            
            System.debug('*** Return Message ***: ' + soapCall.ZsfOrderCreate(orderRemake).item[0]);
        } catch (Exception ex) {
            ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,' ' + ex + '. On line #: ' + ex.getLineNumber());
            ApexPages.addMessage(errormsg);
            isRedirecting = false;
                
            //return null;
        } finally {
            /**************************************************************************
             * Notes       : Creating a new case regardless of the Webservice failing
             *************************************************************************/
           
            System.debug('*** counter ***: ' + counter);
            counter++;
            System.debug('*** counter + 1 ***: ' + counter);            
            insertedNewCaseId = newCase.Id;
            system.debug('Id of the case created in remake method.....'+insertedNewCaseId);
        }

        //return null;
    }

 

 Kindly check and suggest me to solve this issue.

 

 

Thanks in advance.

 

Regards,

kumar

OzZiE90OzZiE90
Hi all, I know this thread is old, but I wanted to update it with an answer that properly works and that is not overly complicated.

In regards to CharlieLang, he/she was close... it should look like this:

<apex:outputLink value="javascript:sforce.console.openPrimaryTab(null, '/{!contact.id}', true, '{!contact.lastName}');">{!contact.lastName}</apex:outputLink>

REMEMBER: remember to include the SF console integration into your page or this wont work...
<apex:includeScript value="/support/console/34.0/integration.js"/>