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
EJN5007EJN5007 

Enhanced pageblockTable Link Behaviour w/ Javascript

Hello SF Decs,

I am using the Service Cloud and am experiencing an issue with URL Landing Pages when links are clicked within PageBlockTables. Below are the two options I have attempted:

OPTION 1 - Works Beautifully, however I need Methods to utilize conditional IF Statement
<apex:pageBlockTable value="{!AuthPartyList}" var="AuthParty">
<apex:column>
<a href="javascript:sforce.console.openPrimaryTab(null , 'https://na15.salesforce.com/apex/{!AuthParty.Party_URL__c}?id= !AuthParty.Party_ID__c}', true, '{!AuthParty.Party_Name__c}', null, null);">{!AuthParty.Party_Name__c}</a>
</apex:column>
<apex:column value="{!AuthParty.Relationship_Type__c}"/>
<apex:column value="{!AuthParty.CreatedDate}"/>
</apex:pageBlockTable>


OPTION 2 - Does not work Beautifully. For some reason, the "CLICK" always behaves as the LAST RECORD IN THE LIST. Click Record 3, System acts as though you clicked record 5 (last record)

<apex:pageBlockTable value="{!OtherActions}" var="action">
<apex:column >
<apex:outputlink onClick="OpenOtherActA();return false">
{!action.Name}
<script type="text/javascript">
        function OpenOtherActA() {
            sforce.console.getEnclosingPrimaryTabId(OpenOtherActB);
        }
        var OpenOtherActB = function OpenOtherActB(result) {
            var tabId = result.id;
            sforce.console.openPrimaryTab(tabId , 'https://na15.salesforce.com/apex/{!action.URL__c}?actionname={!action.Name}', true, ' ', null, null);
        };
    </script>
</apex:outputlink>
</apex:column>
</apex:pageBlockTable>

PLEASE HELP!
Vamsi KrishnaVamsi Krishna
Hi,
can you explain your requirement on using conditional IF statements with the first option.. I can suggest code changes based on your requirement..
EJN5007EJN5007
Vamsi,

I got it working. Thank you for your response. 

Below is the working code. 

<apex:pageBlock mode="edit" title="Frequent Actions">
<apex:pageBlockTable value="{!FrequentActions}" var="action">
<apex:column >

<A HREF="#" onClick="openPrimaryTab('{!action.External__c}', '{!action.ID}', '{!action.Name}', '{!action.URL__c}');return false">{!action.Name}</A>

<script type="text/javascript">
function openPrimaryTab(external, id, name, url) {
            if(external == 'true'){
            sforce.console.openPrimaryTab(null, 'https://na15.salesforce.com/apex/' + url, true, ' ');
            }
            else{
            sforce.console.openPrimaryTab(null, 'https://na15.salesforce.com/apex/' + url + '?id=' + id, true, ' ');
            }
        }
</script>

</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
EJN5007EJN5007
The only thing I need now is to get the OPENPRIMARYTAB variable working instead of "null" :-) Your thoughts?