0

A little help for a button script

Hi

 

I have 2 tables that I d' like to link with a button

 

The script button is :

 

do as server

for i in select Table2 do

let myRec:= i. 'Couleur' ;

let mySup:= first( select Table1.  [ Couleur = myRec] ) ;

i. ('Lien T2 à T2':=mySup)

end

end

 

I get that error :

 

"Expression must return a number or record id:mySup on the line 5, column 26"

 

Can someone explain me this issue with the id or record number ?

 

Thank you

72836A86-6582-4B63-91B8-38363C643FF0

13 replies

null
    • Addinsell
    • 2 yrs ago
    • Reported - view

    C4F1567F-ACEC-4D33-B8AC-B5C097B82909

    • Addinsell
    • 2 yrs ago
    • Reported - view

    39673E95-4F2C-4A75-9DCC-8B05C8341347

    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view

    maybe this is the cause:

    Table1. Remove the dot after 'Table1' in your code

    Steven

    • Addinsell
    • 2 yrs ago
    • Reported - view

    Thanks a lot Steven.

    No more error indeed but nothing happens when I click on the button…

    • Fred
    • 2 yrs ago
    • Reported - view

    I recreated your DB and this is the code that worked for me:

     

    for i in select Table2 do
    let myRec := i.couleur;<--I didn't capitalize this field name
    let mySup := first((select Table1)[Couleur = myRec]);<--this is how Ninox formatted this section
    i.('Lien T2 à T2' := mySup)
    end

     

    The only difference I could see is that yours had spaces after every period (.). Ninox is supposed to strip those spaces out.

     

    Anyways, give it a try.

    • Fred
    • 2 yrs ago
    • Reported - view

    It just came to me, I thought you are running in iCloud, so you can drop the do as server. It doesn't hurt it but it is not needed.

    • Addinsell
    • 2 yrs ago
    • Reported - view

    Thanks a lot Fred.

    No error either but the button does not work : no action.

    • Addinsell
    • 2 yrs ago
    • Reported - view

    By the way what do you mean by : 

    let myRec := i.couleur;<--I didn't capitalize this field name

    • Addinsell
    • 2 yrs ago
    • Reported - view

    anyway here is my script now :

    for i in select Table2 do

    let myRec := i.couleur;

    let mySup := first((select Table1)[Couleur = myRec]);

    i.('Lien T2 à T2' := mySup)

    end

    • Addinsell
    • 2 yrs ago
    • Reported - view

    Please find my 2 tables 

    0D637F21-A3C5-4E5B-812B-4B95E6435E48

    • Addinsell
    • 2 yrs ago
    • Reported - view

    36CE3836-E9E6-48F5-8B50-B1B00F037E95

    • Fred
    • 2 yrs ago
    • Reported - view

    Remember to make sure the field names in formulas match exactly to your field names. So in Table2 the field name is spelled "Couleur", so you need to make sure line 2 reads:

     

    let myRec := i.Couleur;

    • Fred
    • 2 yrs ago
    • Reported - view

    Looking at your screenshots, the button is "not doing anything" because Couleur in Table2 has not data to match in Table1.Couleur. "Nothing" is linking because Ninox can't find any matches.

Content aside

  • 2 yrs agoLast active
  • 13Replies
  • 938Views