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
Jamz_2010Jamz_2010 

List view Custom Buttons

Hi all,

 

Does anyone know of a way I can use a list view custom button to iterate through all the records that have been selected (via the checkbox) in the list? If this is not possible, is there anyway I can achieve the same functionality through a VisualForce page (again using checkboxes to select the records required)?

 

Thanks

 

James 

Best Answer chosen by Admin (Salesforce Developers) 
Jamz_2010Jamz_2010

Right, given the fact that I posted this message twice and have still not gotten a reply! I have found out how to do this, you simply use the:

 

var ids = {!GETRECORDIDS($ObjectType.Contact)}

 

As part of the execute javascript within the button, you can then pass this in the URL by using:

 

 window.open("/apex/myPage?ids=" + ids.join(','));

 

The problem with this is you are limited to 255 characters in the URL. Alternatively, you can use javascript to invoke an apex method my using:

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}

{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

 

sforce.apex.execute("myClass","myMethod",{selectedIds:ids});

 

I hope this helps anyone who also needs to do this.

 

James