0

Button for create a new record which has a connection to a record

I have a table, where in every record, i have a connection of records from a different table showing up.  (1:N)
when want to get a new record, normally click "+ Neuer Datensatz" at the 1:N, and there i get a new record, which already has automatically a connection to the table. But then i use a button with the code:

create TableName

it just gives me a new record, but no connection to the table i am in.

 

4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Fred
    • Fred
    • 2 wk ago
    • Reported - view

    You can check out this post.

    Like
    • Fred thank you! My problem is just, i cant understand how i can apply this what i need, from this other post. Can you help me on that?

      Like
    • Fred
    • Fred
    • 11 days ago
    • Reported - view

    I can try.

    You have a good start with:

    create TableName
    

    The issue you are encountering is you have not specified the record to link to the new record in TableName. Since I don't know the structure of your DB, let us start with the following:

    2 tables - Table1 and Table2

    Table1 is your main table with a 1:N relationship to Table2. There is a field in Table2 called 'linktoTable1' which is the reference field to Table1. It is not just a plain text field.

    So in Table1 we create a button with the following:

    let t := this
    let newRec := (create Table2)
    newRec.linktoTable1 := t
    

    Line 1 creates a variable t that stores the Ninox recordId of the current record.

    Line 2 creates a variable that first creates a new record in Table2.

    Line 3 then takes that new record in Table2 then links the reference field 'linktoTable1' to the record that stored in the variable t.

    Like 1
    • Fred Very great explained! Thank you very much!

      Like
Like Follow
  • Status Answered
  • 10 days agoLast active
  • 4Replies
  • 49Views
  • 2 Following