0

Inserting a record in a Child Table from a Script

Supose I have a parent table with 2 fields and 2 records, linked to a child table:

Table: "MASTER"
Fields: "PK", "COLOR"
2 Records: 
(10; "Blue")
(20; "Red")

And a child table with two fields:

Table: "PRODUCT"
Fields:  "Type", "Amount"

On the Console Panel I'm trying to create a record in the child table but do not know how to reference the parent table.
The PK (primary key) field remains blank.
I'm trying to use the following code:

let p := create PRODUCT;
p.Type := "Box";
p.Amount := 115;
p.??? := 10  (PK field should go here - I think - but it doesn't work)

How can it be done?

2 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    If you are trying to link the records you would do something like this...

     

    let p := create PRODUCT;
    p.Type := "Box";

    p.Amount := 115;
    let masterTableId := item((select MASTER where PK = 10).Id, 0);
    p.(MASTER := masterTableId)

    • JGM
    • Jose_Monteiro
    • 4 yrs ago
    • Reported - view

    Worked fine.

    This is exactly what I need.

    Thank you very much for your help. :)

Content aside

  • 4 yrs agoLast active
  • 2Replies
  • 1112Views