0

using the selection of dynamic choice fields to autofill a text field with data from the table used by the dynamic choice field.

Response and mitigation fields are TEXT fields

Table 1
Field called ‘Response’ dynamic choice refeencing table 2
Field called ‘mitigation’

Table 2
Field called ‘Response’
Field called ‘mitigation’

 

I want to make a selection in table 1, field ‘Response’
And then have the field in Table 1 called ‘mitigation’ autofilled with the text from the same records as selected in table 2 called ‘mitigation’

 

Basically a dictionary type lookup.

4 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    Hi Louis -

     

    Do you want the data from Table2-mitigation copied to Table1-mitigation?

     

    or

     

    Do you just need to see what the data is in Table2-mitigation when you select a Response?

    • Fred
    • 2 yrs ago
    • Reported - view

    Hi Louis -

     

    Sorry, you said you want the data copied. So you can put something like this in a button in Table1 to test it out:

    let x := record('Table 2',number(Response));
    mitigation := x.mitigation

     

    The first line uses the record command to take the record ID from the Response dynamic choice field and find the corresponding record in Table2.

    Then it tells Ninox to make the mitigation field equal to whatever is in the migitation field in the record found for the variable x.

     

    If that does what you want then you can copy the code into the Trigger after update for the Table 1 - Response field, so whenever you update this field it will udpate the mitigation field.

     

    I ask the second question because if you don't need to copy the data and just need to see it then you can create a formula field with:

     

    let x := record(Years,number(Years));
    x.code

     

    And whenever you change Response the value here will show the corresponding value from Table2. No data needs to be copied.

    • NYNNA
    • Louis_Cornacchia
    • 2 yrs ago
    • Reported - view

    That worked Fred. Thank you.

    • NYNNA
    • Louis_Cornacchia
    • 2 yrs ago
    • Reported - view

    interesting little bug.

     

    if I create another set of files to do the same thing, the code does not run unless I run it in a button first. 

     

    loaded the code into field's "trigger after update'

    did not work 

     

    then I loaded the same code into a button. 

    Clicked the button and it worked the first time.

    then I changed the value in the field with the same code, and it worked. 

    Have you ever seen this?

     

    It's as if the code did not load from the field until it first loaded from the button. 

Content aside

  • 2 yrs agoLast active
  • 4Replies
  • 262Views
  • 1 Following