0

Select all choice in a multiple choice (dynamic)

Hi!

In a trigger after update of a field (YES, NO), I would like the code select all options in a multiple choice (dynamic) if YES,

Which code should I use?

Thanks!

9 replies

null
    • Fred
    • 1 yr ago
    • Reported - view

    You can try something like:

    let selDMC := for loop1 in numbers(dMCfieldname) do
    record(tablename,loop1)
    end

    This will put all selections of a dMC into an array. Change the following:

    dMCfieldname

    tablename

    to match your specific environment.

    • Web_Namer
    • 1 yr ago
    • Reported - view

    Sorry, I didn’t make myself clear.

    I have a field1 Yes/NO

    I have a multiple choice field "One","Two","Three","Four","Five".

    I would like this:

    when the field1 checked (Yes), all the elements of the field2 would have checked.

    • Fred
    • 1 yr ago
    • Reported - view

    Sorry, misread your post. Here is what you can put in your trigger after update:

    let allTable := (select Table1);
    if YN then dMC := allTable end

    Change the following references to match your environment:

    Table1 = the table name where the dynamic Multichoice points to

    YN = the yes/no field

    dMC = dynamic multi choice field name.

    Thankfully Ninox allows multichoice fields to be set by an array. Line 1, we start by creating an array with all of the records from the table.

    Line 2, we check to see if the Yes/No field is true and if so then set the dMC to be equal to the array we just created.

    • Web_Namer
    • 1 yr ago
    • Reported - view

    Fred  

    Thank you so much!
    It works!
    But I didn’t understand why the expression

    dMC := (select Table1)

    selects all the elements.

    And then why is it just for the current record?

    • Web_Namer
    • 1 yr ago
    • Reported - view

    I’m having trouble entering this code into the database that’s on Ninox’s server.

    It works perfectly in the imac app.

    The server reports the following error: "Field must return dynamic values: allTable in linea 1, colonna 57.

    This is the code I entered:

    let allTable := (select 'Natura Giuridica');
    if 'Seleziona la natura giuridica aziendale' then
        'Natura Giuridica Aziende' := allTable
    else
        'Natura Giuridica Aziende' := null
    end
    
    • Fred
    • 1 yr ago
    • Reported - view
    Web Name said:
    And then why is it just for the current record?

     Usually a trigger after update of a field only affects the record you are on.

    Are you asking to make the trigger affect ALL records in the table?

    • Web_Namer
    • 1 yr ago
    • Reported - view
    • Michael_Blechinger.1
    • 1 yr ago
    • Reported - view

    this code worked for me. In my case I wrote every Fieldnumber, which needs to get selected and if the "Yes/No" Field is turned off again, the selections in the multiple Choice Field are made undone.

     

    let allTable := (select Vorausplanung);
    if 'Alle Monate auswählen' = true then
        Monatauswahl := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    else
        if 'Alle Monate auswählen' = false then
            Monatauswahl := [0]
        end
    end
    

    In this case Vorausplanung is the Table where I want to get the code executed

    'Alle Monate auswählen' is the ON/OFF Switch
    'Monatauswahl' is the Multiple Choice Field with 12 months.

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 9Replies
  • 451Views
  • 4 Following