Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Sub table or detail table add record?

Forum

Search UsersRules
Sub table or detail table add record?
#1
Active user
Points:: 0
Joined:: May 9, 2018

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

Profile
#2
Active user
Points:: 0
Joined:: May 9, 2018

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);

Profile
#3
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hello Erdoğan,

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

Profile
#4
Active user
Points:: 0
Joined:: May 9, 2018

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.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.