XData Server Confusion

Hi,

I'm confused again.

When using an TXDataWebConnection and an TXDataWebDataSet when I post the data it updates screen daatabase controls but does not post it to the remote server.

What else do I have to do to get it to update the server database?

Thanks,

Ken

Hi,


Its a 2 part process.  

First -  From XDataServer make sure you have DefaultEntitySetPermissoins set properly [Post, Delete, Update etc...].  This used to be automatically set but for security concerns you have to now set it.

You already found your CORS issue.....

Second - The datasets are handled like normal in that the Post is called when datasets are updated.  However this only happens locally to the data at the app/client side.  In REST environments you have to tell you app to post/push those changes to the server.  For this I added TXDataWebDataSet.ApplyUpdates to my AfterPost Event  which pushes the data to the server after edits.  

Start there and post back.  One of the TMS Team will jump in if you have troubles.

Hope this helps.

Thanks Scott. It was the ApplyUpdates that I was missing!

One further thing. This is not sorting the dataset. In what order should I do this?

  tblCompanies.QueryString:='$filter=UserID eq '+IntToStr(UserID)+'&orderby=CompanyName';
  tblCompanies.Load;



Remember that the data strings in the QueryString have to be quoted.  You are working with JSON at some level.

UserID eq 1 -  WRONG
IserID eq '1' - CORRECT

Give this a shot:
'$filter=UserID eq '+ QuotedStr(IntToStr(UserID))+'&orderby=QuotedStr(CompanyName');

or something similar to set up the query string before assignment.


Note for above - I assumed your UserID was a string.  You can adjust the query as needed.  Numeric values are perfectly acceptable in the QueryString if they are in fact numeric.  In that case I'd suspect the failed filter was because of CompanyName.

In case I missunderstood your question - lots of info for 



I wish we cold edit our posts...  Also you are missing a $ in front of orderby.  


I could have cleaned all that up in a single post that made sense :-)
Hi Scott,

Thanks for your posts.UserID is an integer and the missing $ was a typo when I entered it. But using QuotedStr still does nothing.

tblCompanies.QueryString:='$filter=UserID eq ' + IntToStr(UserID) + '&$orderby=' + QuotedStr('CompanyName');

The original problem was the missing $, only. As Scott mentioned later, CompanyName is an identifier, not a string, so no need to quote it:



tblCompanies.QueryString := '$filter=UserId eq '+ IntToStr(UserId) + '&$orderby=CompanyName';

Wagner R. Landgraf2019-05-15 23:23:35

Thanks, that resolved it.