Sub table or detail table add record?

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: May 9, 2018
Company: GOLDENNET BİLGİ TEKNOLOJİLERİ

Hello.
I have a document table. It has sub tables in it. I can add rows to the document table with code. How can I add a record to a subtable?

Code
RowMaster= Documents.MasterDocumentTable.FindByAttribute("Col1", "ABC");
RowMasterRef = RowMaster.Ref.GetObject();
SubNewRecord = RowMaster.DetailTable1.Add(); ??
...
...


* MasterDocumentTable
 |
 ->Col1
 ->Col2
 |
 |__DetailTable1
    ->Col1
    ->Col2
 |
 |_DetailTable2
   ->Col1
   ->Col2

 
#2
People who like this:0Yes/0No
Active user
Rating: 2
Joined: May 9, 2018
Company: GOLDENNET BİLGİ TEKNOLOJİLERİ

Hello. I am writing the solution to the problem.

Code
RowMaster= Documents.MasterDocumentTable.FindByAttribute("Col1", "ABC");
RowMasterRef = RowMaster.Ref.GetObject();
SubNewRecord = RowMasterRef.DetailTable1.Add();
SubNewRecord.Col1 = "A";
SubNewRecord.Col2 = "B";
RowMasterRef.Write(DocumentWriteMode.Posting);

Edited: Erdoğan Uğuz - Dec 29, 2022 11:54 PM
 
#3
People who like this:0Yes/0No
Administrator
Rating: 18
Joined: Oct 3, 2019
Company:

Hello Erdoğan,

could you show a screenshot from the Designer with the structure of this document?

 
#4
People who like this:0Yes/0No
Active user
Rating: 2
Joined: May 9, 2018
Company: GOLDENNET BİLGİ TEKNOLOJİLERİ

Hello.
I changed the design. My first model was useless. Inadequate in query usage. That's why I split the tables. But the code I wrote is correct.

Download 111.png (18.56 KB)
 
Subscribe
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.