[SalesForce] GETRECORDIDS on Activity List view

I created an activity list button to select multiple records from a list view and process in a visualforce page/apex controller. I used GETRECORDIDS($ObjectType.Event) to get Ids of selected Event records. BUT it returned ids of tasks too. Then I replaced $ObjectType.Event by $ObjectType.Task the returned result was same. I then replaced it by $ObjectType.Contact still the returned result was same.

My question is if selected ids are returned irrespective of the $ObjectType.object then why it is there?
Am i missing something?

Here is the code on the Button:

var ids = {!GETRECORDIDS($ObjectType.Event)}; 
if (ids.length) { 
window.location = '/apex/mypage?ids=' + ids.join(','); 

} else { 
alert('Select one or more Records'); 
}

Best Answer

The list button you have created on Activity(combination of tast and event in salesforce) object, so it will always return the ids of activity(Event+Task) regardless of what type you are using with $ObjectType.

So the conclusion is you can use only type for which your list button is created.

example if you create a list button on contact then in the javascript, you can use GETRECORDIDS($ObjectType.Contact) or even pass any other object name or any value like GETRECORDIDS('XXX') still it will return the contact ids only. function GETRECORDIDS requires one parameter so you need to pass the value for the first parameter.

Related Topic