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
naveen reddy 19naveen reddy 19 

List view button to call controller method

Hi,
 My requirement is

1)Need to add abutton to Account list view page say ex:'Process Selected'

2)Whenever I select the list of records and click 'Process Selected' , It should peform contoller action and should not redirect to any other page.

3)What type of button should I use and How to call contoller method from List view Button.

4)Only for this button we need to execute controller method for remaining all logic is standard logic only.

Any help is really appreciated

Thanks in advance.

User-added image

Regards,
Naveen.
Shashikant SharmaShashikant Sharma
You have to choose the Execute Java script option for the button and then you could call a webservice method from an apex class.

Like here: 
http://www.infallibletechie.com/2012/10/calling-apex-method-from-custom-buttom.html
http://blog.shivanathd.com/2014/07/call-apex-class-from-custom-button-salesforce.html
 
NagaNaga (Salesforce Developers) 
Hi Naveen,

Please see the sample code below

User-added image

Best Regards
Naga Kiran
naveen reddy 19naveen reddy 19
Thank you for the response.

User-added image



Getting below compile error


User-added image

Pls help me how to proceed..

Regards,
Naveen.
Shashikant SharmaShashikant Sharma
Make List<Account> accnts as Static as you want ot use it in a Static webservice method.

public static List<Account> accnts = new List<Account>();