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
13 replies
-
-
-
maybe this is the cause:
Table1. Remove the dot after 'Table1' in your code
Steven
-
Thanks a lot Steven.
No more error indeed but nothing happens when I click on the button…
-
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)
endThe 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.
-
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.
-
Thanks a lot Fred.
No error either but the button does not work : no action.
-
By the way what do you mean by :
let myRec := i.couleur;<--I didn't capitalize this field name
-
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
-
Please find my 2 tables
-
-
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;
-
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
- 3 yrs agoLast active
- 13Replies
- 951Views