0

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.

6replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    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.

    Like
    • TNT
    • OregonMines
    • TNT
    • 2 yrs ago
    • Reported - view

    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.

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    Are you trying to create a Reference between tables? If so, take a look at this...

     

    https://ninoxdb.de/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/is-it-possible-to-link-automatically-via-a-function-fields-in-two-tables-that-contain-the-same-text-5c6aaf80e850ad238982b496

     

    ...if not, I guess we'll try again. :)

    Like
    • TNT
    • OregonMines
    • TNT
    • 2 yrs ago
    • Reported - view

    <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.

     

    </p>

    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.

    Thanks again

    Like
    • Sean
    • Sean
    • 2 yrs ago
    • Reported - view

    At a glance, you have it backward. Should be...

     

    myTable1Id := (select Accounts).Id

    and

    for j in (select Assets), etc.

     

    https://ninoxdb.de/en/manual/calculations/reference-of-functions-and-language

     

    I have to go to work so I'll be out of pocket until later tonight.

    Like
    • TNT
    • OregonMines
    • TNT
    • 2 yrs ago
    • Reported - view

    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)
    end

    Like
Like Follow
  • 2 yrs agoLast active
  • 6Replies
  • 1642Views