You need to sign in to do that
Don't have an account?

List Button - Force record selection before redirect to VF
I have a List Button placed on a related list which redirects to a VF page. The controller behind the VF page retrieves the list of selected options and the user then performs some operation on those options.
I would like to prevent the redirect to the VF page if the user has not selected any records. I've tried changing the button to a Onclick Javascript and I can detect whether or not there are any options selected, but I'm unable to then Submit their selection and redirect to the VF page. More precisely, I can submit and redirect to the VF page, but the selected options aren't recieved by the controller.
Is there a way to do this?
Here is the javascript on my List button
records = {!GETRECORDIDS($ObjectType.Job_Applicant__c)}; if (records.length < 1) { alert('Please select one or more options first.'); } else { this.form.action = '/apex/MyVFPage'; this.form.submit(); }
Appreciate any suggestions. Cheers.
An update to the above. I can get it to work, but I have to hardcode the link to the VF page, ie:
Is there a function that will give me the full path to the VF page? ie. https://c.ap1.visual.force.com/apex/MyVFPage
Or is the c.ap1.visual.force.com something that will never change?
Try this:
{!$Page.MyVFPage}