Validation

  

Hi,


I'm newer on OutSystems. My doubt is about how to set a field based on minimum value result for a comparision between three fields.


For example:


I have 4 input values: inputA, inputB, inputC and inputSmaller. I would like to get the small value bettween  inputA, inputB, inputC and set this value on inputSmaller.


How can I do this on OutSystems?

Hi Raphael,

Each input will be bound to a variable (if they are in a form, probably an attribute of the Form.Record).
Lets say variables A, B, C and smaller.

When the user submit the data to server (with a button set to Submit, for example), you can use an assign that does like this:

smaller = min(min(A, B), C)

As you called with a submit, the input will be refreshed.

Of course, you can setup screen actions to be called on the "OnChange" event of each input and do this every time something changes in the inputs A, B and C, and using the Ajax Refresh Action to refresh the SMALLER input.

Cheers,
Eduardo Jauch

You make an assignment to the variable bound to the InputSmaller, with the logic to get the lowest value.

You can use a platform function to get the minimum, or do with if.

SyntaxEditor Code Snippet

SyntaxEditor Code Snippet

If(inputA<=inputB and inputA<=inputC,inputA,
If(inputB<=inputA and inputB<=inputC,inputB,
inputC))

Then you must update the input with the AjaxRefresh widget



Huarlem Lima and Eduardo Jauch both options are good.

But I will recommend to go with Eduardo's approach since it is straight forward and will take less efforts for maintenance.