Why is Formula Editor changing my variables?
I'm writing code to create a new record in a Clients table and copy some fields from the current table. The editor is changing a variable and causing an error. The error is "Return type mismatch for then and else expressions". The code is written as and there is no error when I type it:
let D := Date;
let F := 'First';
let L := 'Last';
let n := (create Clients);
n.('First Name' := F);
n.('Last Name' := L);
After I exit the editor there is an error because the editor has changed my code to:
let D := Date;
let F := 'First';
let L := 'Last';
let n := (create Clients);
n.('First Name' := F);
n.(D := L);
Since D is a date it no longer matches L which is text. But WHY is the editor making the change in the first place?
The 'Last Name' field is indeed text in the Clients table. In troubleshooting I created a new Text field in the Client table and it works without editor making any changes. But changing the 'Last Name' field over to a new Text field is not practical as it is used in many other formulas.
Interestingly if I change the order of the code, BOTH variables are changed!
n.('Last Name' := L);
n.('First Name' := F);
n.(D := L);
n.(L := F);
What the heck is going on???
2 replies
-
I would try changing the variable names to something other than single capital letters. I think your variable names are conflicting with internal Ninox Ids. You might want to look at this even if you are using the Mac app...
-
Oh my goodness...that was it! I will have to be more careful when creating variable names. Weird that it worked when I created a new text field in the Client table. Oh well. Thanks for the quick response Sean!
Content aside
- 4 yrs agoLast active
- 2Replies
- 707Views