Create n records in a subtable at once
Hi NX community!
I have a table "A" which contains several records. I'm trying to come up with some code to set a button that should update the table "B" with all of the records coming from "A".
That would be a lot easier if one could just print a table view! But somewhere in this forum someone said that this is not (yet?) possible.
Does anybody have a hint about this?
Browse for two topics.. First.. "loops" .. you will see an example of looping through records with a select.. Then search for "create" .. you will see an example for creating a record. Combine the two examples.. and put the code in a button on either "Table A" .. or another table.
Hope that helps.
Gsechi - the easiest way to do this would be to use a For loop structure with an embedded create record function. The syntax for this is as follows:
1 for p in 'TABLE A' do
2 let q := (create 'TABLE B');
3 q.('Field 1' := p.'Field 1');
4 q.('Field 2' := p.'Field 2');
The concept here is that in line 1, the variable p becomes a reference to the source table (TABLE A). In line 2, the variable q becomes a reference to the destination table (TABLE B). Then, in lines 3 and 4 and beyond, you are instructing Ninox to insert into the each field of the destination table the value of the corresponding field in the source table.
HI everyone, I have a similar question and i need some ideas or help:
I have a table "VISITE" (with field1 and field2) where i would like to have a formula button to create a new record in a another maintable and its childtable. For example:
I have a table "PARCELLE" with a fieldA, fieldB and a childtable "PRESTAZIONI" with fieldX and fieldY
In the button i would like to have a fomula to :
1) create a new Record in table PARCELLE where fieldA:=field1 and fieldB:=field2
2) create a new related childtable PRESTAZIONI where fieldX:=field1
3) popup this record
I was able to do point 1 but i'm not able to create the new record in the childtable.. Would you mind to help me? Sorry i'm not good with explanation especially in english, I apreciate any suggestion, thanks
I've tried this...
let xid := ID;
let xcli := field1;
let xdata := field2;
let xnp := (create PARCELLE);
xnp.(fieldA := xdata);
If i stopped here, it works, but i would like to create also the linked childtable PRESTAZIONI and linked some field to VISITE.