[SalesForce] Get IDs of checked/ticked records, from list view, in Customer Portal

My custom button works in normal Salesforce UI, but not working in Customer Portal.

OnClick JavaScript:

var contactIds = {!GETRECORDIDS($ObjectType.Contact)}; 
if (contactIds.length != 2) { 
    alert("Exactly 2 Contact records are to be selected"); 
} else { 
    alert("Okay"); 
}

Why is this only working in Salesforce UI and not in Customer Portal? On clicking the custom button, how to get IDs of checked/ticked records, from list view, in Customer Portal?

Best Answer

The list view which is presented in the native platform UI is a lot more sophisticated than the one presented in the Customer Portal. Your JavaScript is not the problem, nor is the getRecordIds function. This is a limitation of the feature in the portal itself.

When navigating between pages of a list view in the customer portal, the page does not retain the state of the selections on previous pages.

The difference in functionality can clearly be seen through the 'selected records' indication in the footer of a native list view counting the number of items selected per page. The portal provides no such information, because it is non-existent (as of Winter '13). The less enhanced functionality can also be seen by the exhibited behavior of losing prior selections when navigating between pages of the list view in the portal.