How can I reference the present record/table in a select statement?
I want to use this select statement in a trigger after update in my Projects table:
select Invoices where SameAsProject = true and Client = Client
I want the first Client to reference Client in Invoices (Invoices.Client)
I want the secound Client to reference the Client of the present record (Projects.Client)
8 replies
-
I want to do something like:
let C := Client;
for I in select Invoices where SameAsProject = true and Client = C do
I.(Client := C)
end..to update all Invoices that has SameAsProject=true when I update the Project Client.
-
Try this...
let C := this.Client
-
Ok now I have this but it's still not working.
for I in select Invoices where SameAsProject = true and Client = this.Client do
I.(Client := this.Client)
end
-
Looks like its giving the right selection for I, but it doesn't change the value in I.Client...
for I in select Invoices where SameAsProject = true and Client = this.Client do
I.(Client := this.Client);
alert(text(I.Id))
end
-
You had...
let C := Client;
I'm saying this...
let C := this.Client;
so it would be...
let C := this.Client;
for I in select Invoices where SameAsProject = true and Client = C do
I.(Client := C)
end
-
When you say you want to update all the Invoices, do mean you want to link the records?
-
Yes, I put this.Client inside the select statement instead of using a variable. Should be the same, right?
For all records in the selection, I want to change the link in
Client
to whatever clientthis.Client
is pointing at.. -
If I recall correctly, I tried to use "this" directly in a formula in the past and it didn't work so I got in the habit of assigning it to a variable. They make changes when they update the app, but don't completely update the documentation. Formerly you needed to use option+return to insert a New Line in a formula, now you can just use return.
Try this to link records to the current record...
let thisId := Id;
let thisClient := Client;
for i in select Invoices where SameAsProject = true and Client = thisClient do
i.(Projects := thisId)
end
Content aside
- 5 yrs agoLast active
- 8Replies
- 1804Views