0

Trouble finding a column

Hello Ninox team!

I’m using the script attached, but Ninox tell me he can’t find a column. Ok Ninox but the column appears well in the side bar and in the table…

Could you please guess why?

6 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • yesterday
    • Reported - view

    Remove the 'Lignes Commandes' in your 11th row:

    t.('Désignation' := d)

    • John_Halls
    • yesterday
    • Reported - view

    Just looking at your code you can clean it up with some simple changes

    1. 'Commande?' = true and  'Commande?' are the same thing

    2. You don't then need a second if to test for false.

    2. t.ID and t are the same thing

     

    let key := this;
    if 'Commande?' then
       let t := (create 'Lignes Commandes');
       let d := Offres.Options.'Fiche Option'.Designation;
       'Purchase Order Primary Key' := t
       t.(OPTIONS := key;
          'Lignes Commandes'.'Designation' := d)
    else
       let pk := 'Purchase Order Primary Key';
       delete (select 'Lignes Commandes' where ID = pk)
    end
    

    In your select, are you sure you want ID = pk? It looks like you are testing for a primary key in one table equalling a primary key in another.

    Regards John

    • John_Halls
    • yesterday
    • Reported - view

    Sorry, from your original issue, it should be

    let key := this;
    if 'Commande?' then
       let t := (create 'Lignes Commandes');
       let d := Offres.Options.'Fiche Option'.Designation;
       'Purchase Order Primary Key' := t
       t.(OPTIONS := key;
          'Designation' := d)
    else
       let pk := 'Purchase Order Primary Key';
       delete (select 'Lignes Commandes' where ID = pk)
    end
    
    

    Regards John

    • Fred
    • yesterday
    • Reported - view

    The reason why you need to remove 'Lignes Commandes' is because you are already in the Lignes Commandes table. You use the variable t. Which is a reference to the create() command a few lines above, which you point to the Lignes Commandes table.

    • frsalabert.1
    • 10 hrs ago
    • Reported - view

    Thanks everybody for your replies. I understand my semantical fault, but when I fix it Ninox tell me: expression return multiple results line 10…

      • Fred
      • 7 hrs ago
      • Reported - view

       it looks like Offres is the many side of the relationship, so Ninox will always assume that multiple records will be returned. Even if you only have 1 record linked, Ninox will return an array.

      If you only have 1 record linked in all the related tables, you need to use the first() or last() command to tell Ninox to only grab 1 record.

Content aside

  • 7 hrs agoLast active
  • 6Replies
  • 24Views
  • 4 Following