0

Show form of combined select (or array) logic

Hello,

I want to show something in a form which is a combination of multiple wheres and conditions.

I want the entries from table_A which have no value in the field bakery. That would look like that: select table_A where bakery = "" or bakery = null. Let's call it result A.

Now I want to get all emails and telephone numbers from table_B. Let's call that result B. Next up I want to show only the results from A where the entries are one of the emails and telephone numbers from result B.

I'd guess we put all all mail and telephone combination inside two-dimensional array and iterate each result from A with this array and display the result. But I am to green with Ninox for the skript behind that.

I would also be happy to just compare one (either mail or telephone number) with my result A.

Thanks in advance 

5 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    So records in A have email and telephone numbers fields to match?

    You could do something like:

    let a := select table_A[bakery = null];
    let b := select table_B;
    let c := a[(var t := this;
            count(b[email = t.email and telephone = t.telephone]))>0]
    

    The first two lines should be self explanatory. The important thing to remember is that using select with no field names tells Ninox to keep track of record level info. Which will come in handy later.

    Line 3 creates a new array that takes array "a" then assigns a variable t that is equal to the Ninox special word "this" for each item in a. Now we can use the record Id to get access to and/all fields in the record.

    Then we take each item in array "b" and search for records in array "a" where the email and telephone matches. We only keep items where the count is greater than 0, which means we have a match.

    Take a look at this post for more info.

    • Thomas.3
    • 2 yrs ago
    • Reported - view

    Uh sweet. Nice! Thank you very much.

    For anyone as green as me: you can display the result with simply writing a

    c
    • Fred
    • 2 yrs ago
    • Reported - view

    oops forgot that part.

    sadly Ninox won’t display the results with just

    c

    since these are the results of a select you need to tell Ninox what to do with the results so you would have to write

    concat(c)

    then you will see a comma separated string og record I’d. 

    • Thomas.3
    • 2 yrs ago
    • Reported - view

    Well if I do:

    let a := (select table_A where bakery = "" or bakery = null);
    let b := (select table_B);
    let c := a[(var t := this;
                count(b[email = t.email and telefon = t.telefon])) > 0];
    concat(c)
    

    I don't get anything shown.

    By the way. I went for another select way in variable a, cuz I have 2 values to check. How do I check it in you syntax?

    And second by the way. On my live system and test system (which is the live system cloned) I need to check it differently to get results. In on I have to check for null and in the other one for "". Which I don't understand. So I went with checking for both.

    • Fred
    • 2 yrs ago
    • Reported - view
    Thomas said:
    Well if I do:
    let a := (select table_A where bakery = "" or bakery = null);
    let b := (select table_B);
    let c := a[(var t := this;
    count(b[email = t.email and telefon = t.telefon])) > 0];
    concat(c)
    I don't get anything shown.

     Then I would say you then have to check that you have the right info in each variable. You can just change out the letter in concat to see that you have any results for each variable. My guess is that bakery = "" is your issue. If the field is empty then you use null. In my test when I switch null to "", I get no results. So you can simplify variable a to:

    let a := (select table_A where bakery = null);
    

    By the way. I went for another select way in variable a, cuz I have 2 values to check. How do I check it in you syntax?

    Just add the field name after the first one, you need to decide if you use an "and" or "or".

    let a := (select table_A where bakery = null and field2 = "something");
    

     

    And second by the way. On my live system and test system (which is the live system cloned) I need to check it differently to get results. In on I have to check for null and in the other one for "". Which I don't understand. So I went with checking for both.

    If the field is empty than you only need to check for null. You can test this by creating another formula field and put the let a line and then change the filters to see what results you get.

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 5Replies
  • 259Views
  • 2 Following