0

Iterate over DC

How can I iterate over a dynamic choice similar to the dynamic multiple choice with numbers(dmc) . My use case is that I would like to auto-select the DC record if there is only one possible choice. 

8 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    That is an interesting question. Why would you have a dC if there is only 1 choice? But let us solve the question.

    You can try this in a button:

    let x := (select dCTable);
    let y := item(x, 0);
    if count(x) = 1 then dChoice2 := y end
    

    Change the following to match your DB:

    dCTable = table that the dynamic choice point to

    dChoice2 = the dynamic choice field

    The weird thing is I can’t put this in a Trigger. If someone else out there knows why I would be interested to know. x and y return a nid value so it should work.

    • Alain_Fontaine
    • 2 yrs ago
    • Reported - view

    Do you mean something like this:

    • Cloud DevOps Fullstack Engineer
    • Martin_Mueller
    • 1 yr ago
    • Reported - view

    Fred I am working on a suggestion algorithm that is based on an existing reference table to suggest the next field based on the already chosen combination and the number of occurrences in the reference table. So it is quite a dynamic algorithm that creates a selection. So that is the reason that the DC can sometimes only have one choice. In that case, it would be awesome if kind of the DC selects itself without that I need to do another lookup ^^.

    • Alain_Fontaine
    • 1 yr ago
    • Reported - view

    It is possible to extend the model with dynamic selections.

    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    And to put the icing on the cake, you can literally automatically select a row in the Choice field. To do this, I added Ninext project and I use an onselected event in the table's tiger can read.

    function onselected() do
        if ChosenRecord then
            'Choice (dynamic)' := number(ChosenRecord.ID)
        end
    end;
    true

    Please, see attached exemple created from Alain Fontaine 's exemple

    Test auto select 2.ninox

      • Kruna
      • 1 yr ago
      • Reported - view

      Jacques TUR hi and excuse for dropping in, but your link leads to a page not found. :-)

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      Kruna oops, here is the example

      Test auto select 2.ninox 

      • Kruna
      • 1 yr ago
      • Reported - view

      Jacques TUR thank you very much :-)

Content aside

  • 1 yr agoLast active
  • 8Replies
  • 135Views
  • 5 Following