I am using Outsystems Platform version 11 and I want to know is there any way to make Outsystems UI dropdown search a mandatory field? What's the best way to go about it?

Solution

Hello Desiree.

I was implementing similar behavior for the radio buttons and what I would suggest is to below your dropdown search, place a text "Required field!" with the class "validation-message".

Wrap it in an IF with the condition verifying if the SelectedItem is empty and if the validations were already running (for example create a boolean local var 'WasValidated' which is False by default but in the beginning of the Save, you set as True). This will prevent the validation message to appear when you access the screen.

In your Save action, you validate if the SelectedItem is empty and if it is - leave the flow (End) and the IF will be refreshed. You can also play with CSS adding a red border to the dropdown.

This should work!


Best regards,


Ania



Solution

I will also go with Anna's suggestion with some small changes. Like

1. Instead of using boolean variable to see if validation is executed or not use it if field is valid or not. So its name could be IsValid, default value to true. In your action if SelectedItem is empty set it to false.

2. Instead ot wrapping your validation message in if widget simpaly set its display/ visible property to show/ hide based on the IsValid variable. No need to check SelectedItem is empty or not.

I am suggesting these changes because if includes, less assignment operation and conditional check :)

 


Thanks Anna. Thanks Nikhil, your answer was similar.