ComboBox and Special Values' List: different values and other linked inputs

ComboBox and Special Values' List: different values and other linked inputs

  

My personal situation:

Tables:

- Legacy (Id, Name, LegacyTypeId, TypeOthers)

- LegacyType (Id, Name)

When LegacyTypeId is not in the ComboBox, It should be possible to define a custom one directly in the Legacy's record, setting description at TypeOthers field.

The Input (set for TypeOthers field) will be visible only when LegacyTypeId ComboBox value is set to "Others".


My solution:

The ComboBox was set to use LegacyType table added by a Special List, defined as:

- 0: (select)

- Others: Others

Even you choose the first or the second one, LegacyTypeId will be set to NullIdentifier() (Outsystems' normal behaviour). So, how to show the correct value in the ComboBox when screen loaded? And how to turn TypeOthers visible in order to show the recorded custom value?

Assuming that everything is set, like:
LegacyOthersInput
- Visible:LegacyComboBox.SpecialListValue = "Others"
LegacyComboBox / OnChange
- AjaxRefresh at LegacyOthersInput
(and others)

Implemented:
Preparation / Assign (after Aggregates)
- LegacyComboBox.SpecialListValue = If(GetLegacyById.List.Current.Legacy.LegacyOthers = "", "", "Others")

Screen / Expression (Escape Content = No) (after LegacyComboBox)
- Value =
If(LegacyForm.Record.Legacy.LegacyOthers <> "",
"<script>" +
"document.getElementById('" + LegacyComboBox.Id + "').selectedIndex = 1;" +
"</script>","")

"selectedIndex" = 1 corresponds to second special value (Others)

Now everything works!
But in my point of view It's not elegant. I think that could be done in another way.

If so, please tell me!!!

Solution

Hi Wilbert,

The Values entered in the Special List are assigned to the Variable specified in the Combo Box's Special Variable Property. If the Variable is NullIdentifier(), you can check the Special Variable to see what was selected.

Solution

Thanks Kilian !!!

So much work while there already was a simple way to do the job.

But everything worth getting a try.

I am still discovering OS!!!!

Thanks your help!

You're most welcome, glad I could be of help. Happy coding!