Mass Update / Calculated Value
I'm trying to make connections between records of 1 table to a 2nd table.
The table where records are to be updated has a field of "Name" that would match the "Name: First" + "Name: Last" of an accounts table.
I'm trying to calculate a value where the connection = the match of Text field, against the Name Fields, returning the record ID ( not text ) of the Account.
Anyone have some code that is similarly handy in function that I could work backwards from? If you are a NX coder for hire, we can talk in that way too.
Could you explain what "connection" means. You can simply select a group of records that match your criteria like this...
let t := this;
select YourTable where Name = t.FirstName + " " + t.LastName
You can also link records based on the same criteria. It's not clear to me what you are trying to calculate and what the record ID has to do with it.
Thanks for the input so far, and I'll try to explain further.
I have a table "Assets" that has a connection called 'Client' that connects to (N:1) the table "Accounts"
In the "Assets" table, I also have a field 'C Match' that has the 'FirstName' + " " + 'Last Name' in it already as plain text. ( Existed from an old Knack workflow )
When I imported a CSV of records into "Assets" , it couldn't fill anything into 'Client' , so I had been going through and searching by 'C Match' fields in the search bar to find records of an account, and then mass update the records. However, when doing this, if trying to set a Constant Value, it requires record ID iteself.
So I'm trying to make a calculated statement for the mass update, where I'd need to return the RecordID(Accounts where (FirstName + LastName) = Assets.'C Match' . While I'm not sure of the exact terminology and functions, this is about the best I can explain it short of sharing a ninox.
Thanks again for any help.
Are you trying to create a Reference between tables? If so, take a look at this...
...if not, I guess we'll try again. :)
<p>Ah yes, sorry, I was using the incorrect terminology.I'm trying to create a reference to Accounts from Assets, where an Account can have many Assets, but an Asset can only have (1) Account. </p>
<p>Trying your code now, when I tried to copy the logic, at the 3rd to last line, it said that Assets in my case wasn't a field. When I replaced Table1 , the editor only allows me to enter field names.
Also, is there a language or programming book you might recommend studying up on that is most similar to NX? I'm trying to learn by reverse engineering code that I get, but it can be slow going.
At a glance, you have it backward. Should be...
myTable1Id := (select Accounts).Id
for j in (select Assets), etc.
I have to go to work so I'll be out of pocket until later tonight.
I ended up getting this done as a Button from Accounts side , that was able to make the connections based on the match. I'm going to try to make the function work in the other direction in an effort to better understand the coding. Many many thanks though, between your code and some other code you've posted in other threads, I got what I needed.
let myid := this.Id;
let myname := FirstName + " " + LastName;
for n in select Assets where 'C Match' = myname do
n.(Client := myid)