0

Select from array

I want a choice type field, constructed from some of the values in another table. Ah, use a Dynamic Choice Field and filter that I hear you say, but the trouble is that the original table has many records with the same data in that field. So the popup choice list is very long with many duplicates and I don't think I can get around that as such a field is intended to work on a list of records and how can it filter only unique values? Which record of the duplicates would it use and which would it filter out. However in this case I only need to use the string value of the chosen option rather than a link to a record in another table.

 

I can instead build an array of unique text values, so I have the exact list of text strings that I want to be able to pick from. But how can I display that array in a way that allows the user to pick one of the values? A Choice type field is either built from a fixed list, or Dynamically from another table. Neither of which work in this case.

 

Is it actually possible to crreate some sort of choice field from an array?

6 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view
    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    Another way would be to populate the dynamic choice with a formula like:

    (select Table1)[let myText := Text;
    Id = first((select Table1)[Text = myText])]

    "Table1" is the source table, where "Text" contains the string value of interest.

    • krunkeriogm
    • 3 yrs ago
    • Reported - view

    The easiest way to use this field is to define the choices option to specify the choices as an associative array where the keys are the labels displayed to end-users and the array values are the internal values used in the form field. This will create a select drop-down.

    If the user selects No, the form will return false for this field. Similarly, if the starting data for this field is true, then Yes will be auto-selected. In other words, the choice of each item is the value you want to get/set in PHP code, while the key is the label that will be shown to the user.

    https://krunkerio.io

    • Ninox partner
    • RoSoft_Steven.1
    • 3 yrs ago
    • Reported - view

    Spam bots are really getting clever these days....

    • UKenGB
    • 3 yrs ago
    • Reported - view

    In the end I found a different way of providing that unique list in all locations it was needed, without having to try and use an array.

    However I can see than being able to use an array in this way could be useful in the future, so these are all really good ideas. Thank you.

    • UKenGB
    • 3 yrs ago
    • Reported - view

    I do wish this forum allowed/provided editing of posts. Apologies for obvious finger trouble.