TXDataWebDataset and Id Values on Insert

I thought that when you applied updates in a TXDataWebDataset the Id was returned and accessible in the AfterApplyUpdates?

I have a SQLServer Database and the field is an autoinc identity field. The code in the WebCore app in AfterApplyUpdates is

var
  lCustomerId, ResolveId: Integer;
begin
  ResolveId := JS.toInteger(TJSObject(Info.Records[0].Data)['CustomerId']);
  lCustomerId := CustomerDatasetCustomerId.Value;
end;

ResolveId has the correct value, but CustomerDatasetCustomerId.Value is 0.

Should I be applying this myself?

Yes.

The Whats New for XData 4.7 (Sep 2019) says

"... This has a good side effect on using TXDataWebDataset as well: when automatically applying updates using [TXDataWebDataset](https://doc.tmssoftware.com/biz/xdata/guide/web.html#using-txdatawebdataset), the id fields will automatically be filled with the server-side generated value."

Is this no longer the case? Or have I misunderstood this?

It's still the case for objects being updated with TXDataWebClient directly.

But indeed, when using the TXDataWebDataset, the underlying object is not being updated anymore. This was a regression introduced in Pas2JS, more specifically in TJSONDataset class. I'm contacting the Pas2JS team to see how this can be resolved.

1 Like

Thanks @wlandgraf I have a work around in place, but it would be good to get it sorted.

1 Like