0

How to query a table using a dynamic combo box value?

I have the code below, i want to return the email address where the the full name of the staff is the one assigned to the ticket.

let i := 'Assigned To';
email(select Staff where 'Full Name' = i)

The code above returning null values, where am i going wrong?

6 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    Hi there:

    May I suggest you try:

    let i := 'Assigned To';
    first((select Staff where 'Full Name' = i).email)
    

    In Ninox you put the field you want at the end of the select.

    In Ninox, when you do a select it always returns an array (even if it is one record), so you need to tell Ninox what you want to do with the array. That is why we need the first command on line 2.

    I hope this helps.

    • John_Halls
    • 2 yrs ago
    • Reported - view

    Fred I thought so too but surprisingly it doesn't work. I spent quite a while trying variants before I found this

    let i := 'Assigned To';
    first((select Staff where Id = number(i)).Email)
    

    and

    record(Staff,number('Assigned To')).Email
    

    Regards John

      • Fred
      • 2 yrs ago
      • Reported - view

      oops, I again didn't read the subject line.

      I guess your solution will work if the record Id from Assigned To matches the one from Staff. We don't know which table Assigned To pulls from.

      If Assigned To does not pull from Staff then something like this may work:

      let i := record('Table of Assigned to',number('Assigned To'))
      first((select Staff where 'Full Name' = i.'insertfieldname').email)
      
      • Fred
      • 2 yrs ago
      • Reported - view

      Reading it again there is no mention if the dynamic choice field is a choice or multi-choice field. This current solution only works if it is a single choice field.

      • MUGANJI_JULIUS
      • 2 yrs ago
      • Reported - view

      John Halls  Thanks a lot the second version solved my problem.

      • MUGANJI_JULIUS
      • 2 yrs ago
      • Reported - view

      Fred Thanks Fred as well for this clarification...

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 6Replies
  • 184Views
  • 3 Following