How do I save table rows that is inserted programatically?

For a proof of concept I have a form with table and a button on top of it. The button have the following code in OnClick event.

if ( BO.F_TableHistory.getLength() === 0 ){
	var rowid = 1;
}
else {
	var lastrow = BO.F_TableHistory.get( BO.F_TableHistory.getLength() - 1 );
	var colid = lastrow.getChildren();
	var rowid = Number(colid.get(0).getValue()) + 1;
}
var newRow = BO.F_TableHistory.createNew();
var newCol = newRow.getChildren();
var dateNow = new Date();
newCol.get(0).setValue(rowid);			//Request ID
newCol.get(1).setValue(dateNow);		//Timestamp
newCol.get(2).setValue(app.getCurrentUserDisplayName());		//Updated By
newCol.get(3).setValue('Update');		//Action
//Add new table row
BO.F_TableHistory.add(newRow);

If I launch the form and click the button I can see rows added to the table. But when I click Save / Submit and go back to open the document, the table is empty. Both Save and Submit are default Stage action button with nothing specified on it. Do I need to add anything to actually those rows that I just inserted ?

Tinus Riyanto - Prisma Global Solusi

It seems you have everything correct. When you hit submit it creates a record with those values in it. If you go to View Responses and open that record the values should be populated in the table. If you open a new form it will be empty.

I've attached a working example (with you code) where submit creates a new record and stores the table values. Opening that record in View Responses shows the table values saved

TableTest.volt.zip

Thanks for the example Ken. It prove that my code works but somehow it fails to save on the proof of concept app. Then I remember that the table used to be linked to a service cal, so I delete the table and said service call and re-create the table with the same name but the new record I added still disappear when document is saved.

Running out of option, I decided to rename the table. Suddenly the new record can be saved. Perhaps there is a cache somewhere.

At least now the proof of concept application work as it should. Thank you very much for your help.