I am getting error, when I call TXDataWebDataset.Append method to add some extra data at client side.
I have a XDataWebdataset on a form and I am getting data from XData service by using SetJSONData method. I am able to see the fetched data in a DBGrid with the help of a linked datasource component.
But I am getting error when I use XDataWebdataset.append method to add a new row. And If I use XDataWebdataset.Insert method then it works fine.
Is this designed behavior or I am missing some point?
//getting data
XDataclient1.RawInvokeAsync('IcallService.GetCustomerCalls', [inMonth, inYear]);
XDataWebDataset1.SetJsonData(TJSObject(Response.Result)['value']);
XDataWebDataset1.Open;
XDataWebDataset1.First;
//adding new record by using append and getting error
XDataWebDataset1.Append;
XDataWebDataset1custno.AsString := 'Cust101';
XDataWebDataset1contact.AsString := '9898989898';
XDataWebDataset1.Post;
You are calling RawInvokeAsync without await. That doesn't wait for the method to return to execute the next statements. Make sure you call it using await.
//getting data
var
res: TXDataClientResponse;
...............
res := await(XDataclient1.RawInvokeAsync('IcallService.GetCustomerCalls', [inMonth, inYear]));
XDataWebDataset1.SetJsonData(TJSObject(Response.Result)['value']);
XDataWebDataset1.Open;
XDataWebDataset1.First;
//adding new record by using append and getting error
XDataWebDataset1.Append;
XDataWebDataset1custno.AsString := 'Cust101';
XDataWebDataset1contact.AsString := '9898989898';
XDataWebDataset1.Post;
But still getting the same above error on XDataWebDataset1.Append
Can you please send a small project reproducing the issue? I just can't tell what's wrong just from the provided code.
Can you maybe try to remove the First call after Open, since it's not needed?
The error seems to be a Grid filling issue. Do you have the same error if you someway disconnect the grid from the dataset, Append, Post, and then reconnect them?