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
CharlieLangCharlieLang 

service cloud, new tab from dynamic list

I have built a dynamic list in visualforce that i am putting in a service cloud solution.

 

when i click on one of the listed items i want it to open a new tab with the relavant info in it.

 

i have used the onclick method but have got to a sticking point, all of the items in the list now pick up the same link.

 

Can someone work out what this is as it's starting to do my head in...

 

<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="OpenPrimaryTab();return false">{!contact.Employee_Number__c}</A> 

                <script type="text/javascript">
                    function OpenPrimaryTab() {
                        //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>

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You'll need to pass the id of the contact through to the javascript.  Something like:

 

 <A HREF="#" onClick="OpenPrimaryTab('{!contact.id}', '{!contact.Firstname} {!contact.lastname}');return false">{!contact.Employee_Number__c}</A> 

                <script type="text/javascript">
                    function OpenPrimaryTab(theId, name) {
                        //Open a new primary tab with the customer details in it
                        sforce.console.openPrimaryTab(null, '/' + theId, true, name, openSuccess, 'CustomerTab');
                    }

 

All Answers

bob_buzzardbob_buzzard

You'll need to pass the id of the contact through to the javascript.  Something like:

 

 <A HREF="#" onClick="OpenPrimaryTab('{!contact.id}', '{!contact.Firstname} {!contact.lastname}');return false">{!contact.Employee_Number__c}</A> 

                <script type="text/javascript">
                    function OpenPrimaryTab(theId, name) {
                        //Open a new primary tab with the customer details in it
                        sforce.console.openPrimaryTab(null, '/' + theId, true, name, openSuccess, 'CustomerTab');
                    }

 

This was selected as the best answer
CharlieLangCharlieLang

Bob. Thats great. Thanks!!!

Mike445Mike445

Hi Bob,

I am trying to open a new primary tab from a subtab. I am successful in opening a new primary tab from a subtab but ON 'openSuccess' I am opening few more subtabs for newly created primary tab. Here is all the problem. Once the primary tab is opened openSuccess is not being called. I am stuck at this point. Can you please help me why its not calling openSuccess function.

 

Thanks.