0

Create multiple records in a subtable?

Hi NX community, some help with code needed here please...

 

In a table "A" I need a button to create n rows in a subtable "B" at once ("n" being a number which can vary from 1 to n). I tried a for loop as follows but it doesn't seem to work:

 

let myID := ID;
let codPrg := 'COD. PROG.';

let user := User;
let n := switch Test do case 1: 3 case 2: 'n° test' end;

let setRow := (
let NN := (create B);
NN.('cod.prg' := codPrg);
NN.(User := if quotaFissa then quotaFissa else null end);
NN.(A := this.myID)
);
for i in range(1, n) do
setRow
end

 

Could anyone tell where I am wrong? Thanks a lot

G

1 reply

null
    • John_Halls
    • 3 yrs ago
    • Reported - view

    Hi 

    You are trying to define a function called setRow. There's no need. In very basic terms use this

    let myID := Id;
    let n := 5;

    Add more variables from Table A here

    for i in range(1, n) do
    let NN := (create B);
    NN.LinkField := myID <-- Change to your linkfield in Table B

    Add more fields from Table B here

    end

     

    Regards

     

    John

Content aside

  • 3 yrs agoLast active
  • 1Replies
  • 378Views