Hello,

Is it possible to display a message depending on the selection on a drop down? For example, in a form with a drop down listing car parts, when the user selects one of the parts if it is not available the page should display a warning message saying that is not available, all this staying in the same page. I'm developing a reactive web app.

Thank you in advance,

Yomarie Hichez

Hello Yomarie,

Yes, that is possible indeed.

In the properties of a dropdown, you'll find an Events section.


You can define a client action and bind it to the On Change Event of your dropdown.

Everytime the user selects a different value, the On Change Event will trigger.


So, in your client action (binded to this event), you should place your own logic to validate if the part is available or not. If not, you can display a Feedback Message. Something like this:

Kind regards,

Rui Barradas

Thank you for your response Rui Barradas. I'm having issues with the logic part 



I did a client action (up) that calls a server action (down). I don't know if I can call the car id with "DropdownUnidad.id" or there is another way to identify witch car am I choosing.


Solution

Hi Yomarie,

Look the .oml, screen example, i think that will help you.

Regards.

Solution

Hello again Yomarie,

More example, this one with validation on the same page.

But the correct one is the first example, using server action.

 Regards.

Hi again Yomarie,

Thank you for sharing your code. Some notes about it that I would like to mention:


1) Your Client Action seems to be correct. You are calling the Server Action, assigning the output to a variable, checking its value, if the output is false (means that the part is not available), you show the feedback message.


2) Your Server Action should receive the Car Part Id as an input parameter and you should check if this part is available or not. Also, you should have an output parameter - call it for instance IsAvailable (boolean type). I'm assuming that you have this information stored in the database, so you should perform a query / aggregate in order to check the availability of that specific car part and assign the result to the output parameter. It seems that you are doing something similar.


3) About your question (how to identify which car part is the user selecting), you can identify this using your Dropdown properties.

What you have is:

Using this DropdownUnidad.Id variable is not what you pretend. This variable is related to the dropdown widget itself and its purpose is to identify this widget instance at runtime. Basically, it allows you to identify this dropdown widget in the HTML.


What you pretend is to use the variable that holds the value selected by the user. That variable is defined in your dropdown properties.


Here's an example. As you can see, there is a property called Variable. This is the variable that holds the value entered by the user (meaning that this variable is binded to the option that the user selected). In this example, this Variable property is binded to the SelectedCarPartId screen variable. Everytime the user selects another option of the dropdown, this SelectedCarPartId screen variable is automatically updated.

This is the value that you should use as an input parameter of your server action (to identify which car part is the user choosing).


Hope that this helps you.

Let me know if you have any further questions.


Kind regards,

Rui Barradas