0

I'm trying to show a custom error message on a list view.I have a List Button on Account whose Content Source is Visualforce. The Visualforce page has a extension which uses StandardSetController. When on the List View user selects Account Records and clicks on the Button it launches the Visualforce page with the details of the Accounts selected.This is all working fine but I want to introduce a validation here i.e when the User Selects more records than recommended(say 25) and click on the button I'd like to throw a Custom Error on the list view.I couldn't figure out to throw this custom error on list view. Any thoughts on this is much appreciated.

public class AccountExtenstion {
public List<Account> selectedAccountRecs {get;set;}
public Integer selectedAccCount {get;set;}


public AccountExtenstion(ApexPages.StandardSetController controller) {
    selectedAccountRecs = controller.getSelected();
    selectedAccCount = selectedAccountRecs.size();
}
}

so if(selectedAccCount > {LIMIT}) I want to throw an error.

1
  • do you have an example if the VF that you have tried? are you possibly using JS to read which items are selected? – Ronnie Jul 13 '18 at 2:59
0

As long as your Visualforce page contains an apex:pageMessages tag, you can output a message in your page by adding this to your constructor:

ApexPages.Message(ApexPages.Severity.ERROR,'Too many.');
0

If you want the error / popup to appear on the standard list view page itself, this cannot be done. You will have to display the message on your Visualforce page, and then provide a button on the VF page that the user can click on to return to the standard list view page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.