Quantcast
Channel: OutSystems Community
Viewing all articles
Browse latest Browse all 1476385

[Forums] How to validate Combo Boxes outside of a form

$
0
0
Thank you Mr. Hekhuis for your fast reply.

Let's see what I have:

1. I have a special list entry already. It first and only option reads "- Products -" and a value of -1 is assigned to that option.

2. The combo box variable, is a variable of type record (a record of the "Multipackage" table). The variable name is "Multipackage", and the property that holds the combo box variable is "Multipackage.ProductId". The variable seems set to be 0 value, because when the user select nothing and I debug the application, the variable hold a 0 value. (Again, the platform seems to set the 0 value by default)

3. The mandatory property of the combo box is set to "mandatory" already.

4. The button validation property is set to Client & Server already.

It still doesn't work :/

What I am missing here?? Thank you!!


Kilian Hekhuis wrote:
Hi Samuel,

First, if you want to ensure the user sets a value, the default for the combo box needs to be a value that's not valid. The easiest way for this is to have a single Special List entry with an Option of "-" or "(please select a value)" or the like (anything that indicates to the user it still needs to select a value). Also, make sure that your combo box's Variable is set to its null value (i.e. NullIdentifier() for an identifier, 0 for an integer etc.). This will ensure the Platform shows your Special List entry.

If you want client-side validation, you need to set the Mandatory property of the combo box to True, and the Button's Validation to Client & Server. If you press the button and the default value is still selected, you get a "Required field" message next to the combo box. Note that in this case, the Action of the Button is not executed.

If you want server-side validation, you need to check the value of the Combo Box's Variable. If it's the null value (NullIdentifier() for an identifier, etc.), you know that the user did not select a valid value, and you can raise an error (with a Feedback Message, or by putting a message on the screen, or by making the combo box's border red, or whatever you fancy).

I hope it's a bit clearer for you now?
 
 

Viewing all articles
Browse latest Browse all 1476385

Trending Articles