Values added on the XDataServer aren't being returned

I am using a TXDataWebDataset and posting to an XDataServer.

On the server, in TXDataServer.OnEntityInserting a value is set to one of the fields. This is inserted into the database, but in the TXDataWebDataset.AfterApplyUpdates this value isn't present.

Any ideas? thanks

Do you have more details? The name of the field, the value being saved, what you are doing on the client with TXDataWebDataset...?

In the web app the Row is inserted into the TXDataWebDataset.

Before posting the row the following code is

 SalesSheetSheetCount.Value := FSheetCount;
  SalesSheetSheetNumber.Value := FSheetNumber;
  SalesSheetBatchId.Value := FBatchId;
  SalesSheet.Post;

On the server the code is

  if TSalesSheet(FEntity).BatchId <= 0 then
     TSalesSheet(FEntity).BatchId := GetNextSequence('SEQ_SALESBATCH');

This works as the value is inserted into the table

Back on the WebApp in SalesSheet.AfterApplyUpdates

FBatchId := SalesSheetBatchId.Value;

Then a bit more processing and finally a SalesSheet.Append for the next entry.

And about what values are talking about here?

  1. What is the FBatchId value before the Post?
  2. What is the BatchId value in the request JSON body sent to the server?
  3. What is the TSalesSheet(Entity).BatchId value received in the server?
  4. What is the FBatchId value in the AfterApplyUpdates event?
  1. What is the FBatchId value before the Post? 0
  2. What is the BatchId value in the request JSON body sent to the server? 0
  3. What is the TSalesSheet(Entity).BatchId value received in the server? 0

3a. Allocated on the server 105
3b. Value after inserting (TXdataServer.EntityInserted): 105

  1. What is the FBatchId value in the AfterApplyUpdates event: 0 - Even stepped through and the dataset when read in afterapplyupdate shows batchid as 0.

What's interesting is that the 2 other fields populated in the server DateAdded and AddedBy are both Null, although are populated in the db. The only field where the data is added on the server which is not the value it was sent with is the Id field which is completed by Aurelius.

That's expected behavior, the dataset doesn't perform additional requests to update the values modified server-side.

I'd have thought that if it sends back the id it would send back the rest, which I'd think is a major part of putting business logic on the server.

The automatic CRUD endpoint returns the updated object, it's just the dataset that doesn't update the object itself. We might include an option for that to happen in a future release.

That would be excellent. But that does mean I can query the returned JSON to get the values?

From the dataset, there is no easy way to hook into that. But of course you can do the request yourself and get the JSON result manually.

or I can wait for you to include the option, as it must be reasonably straight forward - and after all why wouldn't you want the latest version of the data? Not having it there might cause inconsistencies if you edited something and updated it, you'd overwrite the chnages made on insert with blanks I guess.

1 Like