Odd Database behavior
I have 2 different databases with the same function where they select a product from a drop down menu(linked table ComboBox) and then it adds the record to the lineitem table. This works in database 1, but not in database 2. They are in the same team space, but I cannot find ANY reason it shouldn't work in DB 2. Any suggestions on where to look?
Is DB2 an exact duplicate of DB1, with just different data? Which means all of the tables are named the same and the only thing that has changed is the data in the tables?
Fred, Yes. However, it has more data. I found what I think the issues is. When I do a select from the table with "This.Id" I get back multiple records. If I add last to the query, I only get back record 9999. If I use first, I get back record 10000. I think this is a bug in the ninox base code set.
This has been reported to support. I will update once we get a fix figured out.
I'm fairly confident this is by design and as far as I can recall users have never been able to use "this" directly. You need to assign "this" to a variable and then you can use the variable for any assignments or comparisons.
I would say that using "this" directly is not really disallowed, but that it is generally useless. "this" represents the record that is current in the active context. Which means that writing "someField" or "this.someField" always designates the stated field in the same, current record.
What makes "this" useful is that its value can be stored in a variable. The variable then keeps its value when the active context has changed.
The canonical exemple of this use is in the formula expressing the desired filter in a "select" statement, either in a "where" clause or inside square brackets. In order to gather the records specified by the filter, the formula is evaluated, in turn, in the context of each record of the table specified by the "select" statement.
Writing a filter formula like "someField = this.someField" will thus gather all the records of the table, because the two sides of the test for equality represent the same field, from the record being checked, when the formula is evaluated. And "someField != this.someField" always results in the selection of no records.
To gather the records of a table where a field has the same value than a field in the table where the "select" statement resides, one must thus save the current value of "this", or the current value of the field of interest:
let me := this;
select targetTable where someField = me.someField
let myField := someField;
select targetTable where someField = myField
The same applies when filtering the records of a related table, using the square brackets syntax.
@Sean/@Alain, Thank you. by setting the local variable to this, I was able to get the function to work properly.