Data Abstract for JavaScript bug inserting new row

Hi
I am trying to insert new row (update is working fine) and I’m getting following error
Error: Field idCol is required.

idCol is primary key of varchar type
The values of added row object debugged in chrome developer tools are:
mapped db fields poperties has all values set
row property state: 2
__newValues array has all values set
__oldValues array has all values undefined

This is two code versions both giving same error:

var objTable = new RemObjects.DataAbstract.DataTable("myDbTable");

objAdapter.getData(objTable, RemObjects.DataAbstract.Util.createRequestInfo(true, -1, "", []),
	function() {
		new RemObjects.DataAbstract.Views.HtmlTableView(objTable, "myHtmlTable");

        objTable.appendRow();
        objTable.rows[objTable.rows.length - 1].idCol = "123-ABC12";
        objTable.rows[objTable.rows.length - 1].dateCol1 = "2017-03-17 16:16:16";
        objTable.rows[objTable.rows.length - 1].boolCol = true;
        objTable.rows[objTable.rows.length - 1].dateCol2 = "2017-03-17 15:15:15";

        objAdapter.applyUpdates(objTable, function(result) {
                        alert("Ok");
                    },
                    function(msg, e) {
                            if (e) {alert(e)}
                            else (alert(msg.getErrorMessage()))
                    });
	},
	RemObjects.UTIL.showError
);

OR

var objTable = new RemObjects.DataAbstract.DataTable("myDbTable");

objAdapter.getData(objTable, RemObjects.DataAbstract.Util.createRequestInfo(true, -1, "", []),
	function() {
		new RemObjects.DataAbstract.Views.HtmlTableView(objTable, "myHtmlTable");

        objTable.onNewRecord = function(row){
            row["idCol"] = "123-ABC12";
            row["dateCol1"] = "2017-03-17 15:15:15";
            row["boolCol"] = true;
            row["dateCol2"] = "2017-03-17 16:16:16";
        }

        objTable.appendRow();

        objAdapter.applyUpdates(objTable, function(result) {
                        alert("Ok");
                    },
                    function(msg, e) {
                            if (e) {alert(e)}
                            else (alert(msg.getErrorMessage()))
                    });
	},
	RemObjects.UTIL.showError
);

Thanks, logged as bugs://77434

Hello

The row’s values are set as expected. The reason for this error should be somewhat else. Could you please send to support@ results of JSON.stringify for objTable and for the row added?

Thanks in advance

bugs://77434 got closed with status cannotrepro.

Hi Anton,
I have fixed this bug.
As you suggested in your post in https://talk.remobjects.com/t/data-abstract-for-javascript-bug-fix/12461/4 to use __onNewRow event. I got “Error: Field idCol is required.” error when using onNewRecord event or update directly as in first code version. And second problem was that you can’t assign string representation of date to date field but you have to assign it JavaScript Date object
like
row[“dateCol1”] = new Date(2020, 3, 17, 15, 15, 16, 17);

Hello

Anyway we’ll spend some time on investigating why the onNewRecord didn’t work for you as it should.

I’ll post an update in this thread after that.

Regards

Thanks, logged as bugs://77477

bugs://77477 got closed with status fixed.

Hello

I’ve improved the library so now such code work as expected too:

function DaTest() {
    var adapter = new RemObjects.DataAbstract.RemoteDataAdapter("http://127.0.0.1:8099/json", RemObjects.DataAbstract.JSONDataStreamer);

    var table = new RemObjects.DataAbstract.DataTable("Customers");
    console.log("Data Load");
    adapter.getData(table, RemObjects.DataAbstract.Util.createRequestInfo(true, -1, "", []),
        function () {
            console.log("Data Load - Done");
            table.onNewRecord = function(row) {
                row["Id"] = RemObjects.UTIL.NewGuid();
                row["Name"] = "Some Name";
                row["Discount"] = 0;
            }
            var row = table.appendRow();

            adapter.applyUpdates(table, function (__result) {
                alert("Ok");
                console.log("Apply Updates - Done");
            },
                function (msg, e) {
                    console.log("Apply Updates: " + e);
                    if (e) { alert(e) }
                    else (alert(msg.getErrorMessage()))
                });
        },
        RemObjects.UTIL.showError
    );
}

I can provide tthe updated library to you via support@ if needed. Also these changes will be available as part of the next Beta build.

Regards

Logged as bugs://i65143.

bugs://i65143 was closed as unable to reproduce.

Logged as bugs://i65179.

bugs://i65179 was closed as fixed.