Assign to a dynamically named variable

Is it possible to assign a value to a variable, where I base the variable on the value of another variable?

To make this more clear: I have a form with multiple fields. On change of a field I want to check the input and if it's wrong, I want to set [fieldname].valid = false and [fieldname].validationmessage = "error". 

I have a variable that holds the [fieldname].typedvalue so I can check this without having to check every field. I also have a variable that simply holds [fieldname].

However, in an assign, I cannot use the [fieldname] to dynamically assign false and "error" to the input box.

Is there a way without having to use many ifs and assigns to make this happen, or will I have to make it complicated?

Hi rob,

I don't understand really well what you are saying but, if, what you want is validate a field, you can use the widgets runtime properties. you can use it in the save logic or in an OnChange logic. This runtime properties will change the Form.isValid like you can see in this picture:


This put the focus on the widget and displays the message that you assign.


Hope that this can help.


Regards,

Ricardo

Solution

Hi Rob,

What you want to do isn't possible in Outsystems.

Regards,

Marcelo

Solution

Ricardo Pereira wrote:

Hi rob,

I don't understand really well what you are saying but, if, what you want is validate a field, you can use the widgets runtime properties. you can use it in the save logic or in an OnChange logic. This runtime properties will change the Form.isValid like you can see in this picture:


This put the focus on the widget and displays the message that you assign.


Hope that this can help.


Regards,

Ricardo

Hi Ricardo,

That is exactly what I want, but I have multiple fields/input boxes (about 10) on the same form. For one field this is easy, you simply check [fieldname].typedvalue with an ifstatement.

The problem is that I have many fields on my form. They all point towards the same "save" action. So if I want to check the typedvalue of the correct field, I cannot simply get the typedvalue of a field. I have to know which field triggered the onChange action. Then, I also need to know this because I want to change the .valid and .validationmessage of that particular field.

Alternatively, I have to make a complicated scheme of nested if statements that checks all fields, and after that, another complicated scheme with ifs to assign the correct [field].valid/.validationmessage. Then I need to do this yet again for turning these messages off if the user corrected the input. This would make this function increadibly more heavy than without the validation.

Marcelo Ferreira wrote:

Hi Rob,

What you want to do isn't possible in Outsystems.

Regards,

Marcelo

Hi Marcelo,

Thank you, I'll make the complicated scheme then. Unfortunate but thanks for the answer.