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
GauravKumarGauravKumar 

Visualforce Page Redirection from LIST VIEW button with record select message ALERT check

I am finding it very irritating in a situation where I implement a Mass Update Button on a List View tab and I've Set the Button as Visualforce Page redirect then I CANNOT display a Message alert for User to First Select records, the way sControls work, I'm stuck here without any check for that button. And I cannot use scontrols for implementing the button.

 

Any suggestion or any info when will salesforce allow us to apply a Record Selection validation alert when we implement a List Button with Visualforce page redirect ?

Best Answer chosen by Admin (Salesforce Developers) 
TomSnyderTomSnyder

here's one way to do it:

 

 

//Execute JavaScript List Buttonvar ids= {!GETRECORDIDS($ObjectType.Contact)}; if(ids.length < 1 ) alert('Please select at least one contact.'); else var mywin = window.open('/apex/mypage?ids='+ids.join(','));

 

 

 

//On Apex init()List<string> IDS = ApexPages.currentPage().getParameters().get('ids').split(',',-2);

 

 

 

 

 

All Answers

GauravKumarGauravKumar
Plz Help ......
Manu ErwinManu Erwin

No idea about the roadmap sorry but as a workaround have you tried using OnClick JavaScript to perform the check for record selection then redirecting the user to the Visualforce page with a URL?

 

Not the nicest but may work.

TomSnyderTomSnyder

here's one way to do it:

 

 

//Execute JavaScript List Buttonvar ids= {!GETRECORDIDS($ObjectType.Contact)}; if(ids.length < 1 ) alert('Please select at least one contact.'); else var mywin = window.open('/apex/mypage?ids='+ids.join(','));

 

 

 

//On Apex init()List<string> IDS = ApexPages.currentPage().getParameters().get('ids').split(',',-2);

 

 

 

 

 

This was selected as the best answer
HARSHABKHARSHABK

Hi,

 

      I am new to Visualforce and I am facing similar problem. Could you please post the sample code here with some details how you used the Javascript.

 

 

Thanks,

Harsha

symantecAPsymantecAP

I am creating a button called VIEW ALL on the accounts. I need help . The button should display a page that contains all accounts. But VF Page is not available for LIST VIEW.kindly help