What is the current scope for formulas in View fields
I'm experimenting with view fields. I have a simple person table that contains a first name and last name. I've added a view field. In that field, I would like to show all people whose last names come before the current record. I tried using something like this:
select Person where Last < this.Last
This
results in an empty view. However, if I hard code a string value in place of "this.Last", the view works as expected. Is it possible to use a value from the current record in a view formula? What scope is active in the view's formula?
3 replies
-
let v := this.Last;
select Person where Last < v
-
Thanks Dean
-
Trying to answer the question about the scope in the original post.
As far as I understand the subject, the scope for the evaluation of the logical expression following the "where" clause is, in turn, each record of the target table.
What about the "this" pseudo-function? The manuel states that "This" is an automatic handle to the current record. No more no less.
In the formula submitted in the original post:select Person where Last < this.Last
"this" is a handle to each record of the target table, in turn. So the formula is comparing "Last" in each record with itself, and asking for an inequality, which can of course never be true. Hence the empty view.
When the scope is already the desired record, adding an explicit "this" is simply redundant. You can verify that the two formulas below also give te correct result:let v := Last;
select Person where Last < v
(in the "let" statement, the scope is alreay the current record, so "this" is redundant and may be omitted)
let v := this.Last;
select Person where this.Last < v
(in the select statement, the scope is each record of the target table, and you may add a redundant, explicit "this" if so inclined).These considerations are the result of personal reflexions and tests, and are not sanctioned by any authority.
Content aside
- 4 yrs agoLast active
- 3Replies
- 544Views