Form Validations in server action

Form Validations in server action

  

Hi All, 


I'm trying to implement certain validations on the input sent through a form in a screen (Generally, we do it in screen action and we check for form.valid is true and if not we set the corresponding widget's Valid and Validity Message appropriately). 


If this logic is to be handled in server action, the widget form might not be available to assign the values for validity. Kindly let me know if any way to over come this apart from creating our own variables to hold the value. 


Thanks in advance.


Thanks and Regards,

Priya

Hi Priya,

Are you developing a Web App or a Mobile App?

Hi Kilian Hekhuis, 


I'm developing a web application. 



Thanks and Regards,

Priya

Solution

Hi Priya,

From a Screen Action you have all the Widgets available that are on the Screen. From a Server Action you don't have any Widgets available (regardless of whether they are currently visible, you just can't use them). You can choose one of two options:

  1. Have all the validation of the input inside a Screen Action, which also sets the Valid etc. The downside is that depending on the complexity of the validation, you are putting business logic in a presentation module, which violates a layered application approach.
  2. Handle the validation in a Server Action by passing, from the calling Screen Action, the necessary data, and return some status information that allows the Screen Action to set the right Valids etc. The downside is added complexity, but you avoid violating a layered approach.


Solution

Hi Kilian, 


Thank you for the suggestions. 


Thanks and Regards,

Priya