0
  1. Created a dynamic form in modal popup based on the fields for a object
  2. One of the field's datatype in the form is number
  3. When user hits save button we have handled to close popup onComplete after action method returns from apex via ajax
  4. We have used ApexPages.Message to add error message and display it in popup
  5. But when user hits save button, Saleforce throws system validation error for number field, the execution is not hitting apex method and closes the popup without prompting inpopup Can we able to handle/capture salesforce system validation and add in ApexPages.Message?
1
  • Is this Visualforce or LWC or Aura?
    – cropredy
    Commented Feb 24, 2020 at 20:07

1 Answer 1

0

It's not exactly clear whether you're working with LWC or VF etc., but maybe a good old fashioned before-trigger would work for your use-case? By running APEX before a save (assuming that's some kind of insert/update for you), you can provide your own validation before Salesforce gets its hands on the invalid data.

Alternatively, there may be a front-end method of ensuring the input is viable before it submits to the server.

2
  • Form renders in modal popup in VF page with multiple tabs and each tab is validated with required field and set error in 'ApexPages.Message' and finally if there is no error then data are saved. But while validating each tab if user enter invalid data for the optional field then system validation is happening and preventing the further execution and popup get closed. I.e if user enter alphabet for the field which type is number, then system validation is preventing and popup get closed. Because all this form validation for each tab is happening in Ajax call.
    – Ganapathy
    Commented Feb 25, 2020 at 5:26
  • There's a few good suggestions for front-end validation here: salesforce.stackexchange.com/questions/31641/… HTML5-style validation should prevent a "submit" button from going ahead. Commented Feb 25, 2020 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .