- Created a dynamic form in modal popup based on the fields for a object
- One of the field's datatype in the form is number
- When user hits save button we have handled to close popup
onComplete
after action method returns from apex via ajax - We have used
ApexPages.Message
to add error message and display it in popup - 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
?
-
Is this Visualforce or LWC or Aura?– cropredyCommented Feb 24, 2020 at 20:07
Add a comment
|
1 Answer
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.
-
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. 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