I mean you include RecId as the sort order, but you are not assigning a value to it in the record buffer prior to the ins statements. The RecId is assigned at the point of the insertDatabase call, so I don’t think it can be included in the SortOrder. I could be wrong, but apparently, it isn’t working for either of us. When I changed it to Id, it worked. I will run a couple more tests, and see what I come up with.
When I modify the sortOrder to use Id, and don’t value the Id, in the record buffer prior to calling the ins method, I only get one record inserted also.
static server void insertDB()
{
RecordSortedList recordSortedList;
SamRecordInsert table1;
recordSortedList = new RecordSortedList(tablenum(SamRecordInsert));
I see your point Krishna, so the insertDatabase must not be assigning recId’s(I could be wrong about that). I was looking at the class you mention, and I suspect that the newLineCollection is being populated from another RecordSortedList that does have RecId’s valued. That’s the only way I can explain it. I am looking to see what is calling the transferlines method (it seems to be outside the class).
Please reference the following lines in that method:
haveRecord = _lineCollection.first(line);
haveRecord = _lineCollection.next(line);
I will research it some more and will post if I find a definite answer for you.
generalJournalAccountEntry.RecId = _ledgerPostingTransaction.GeneralJournalAccountEntry;//recId being assigned // temporaly but at the time of insert in the table the recid value will be differnt
so by changing my code will insert the multiple records…
If you look at LedgerPostingGeneralJournalController.addLine, you wil see that lineCopy.recId is being assigned the this.getNextTemporaryRecId();
This could take a while to trace back, but look at addCore, addLine, and transferReferences, and I think you will find that the recId is being assigned.
public RecId getNextTemporaryRecId()
{
nextTempRecId++;
return nextTempRecId;
}
I believe the recId to be temporary though, and that the insertDatabase will ultimately assign the real recId.