Data of fields which have relations

I have a master and detail table and I have set the relationship in the database

{
  • value
    [
    • {
      • $id1,
      • CustomerName"COMPAS ",
      • Min1null,
      • Min2null,
      • Max1null,
      • Max2null,
      • CreatedBynull,
      • CreatedDatenull,
      • ModifiedBynull,
      • ModifiedDatenull,
      • Customer_id@xdata.ref"Customer('C001')",
      • Service@xdata.ref"Service('%25%20Butyl%20Cell')"
      },
    I have the a Xdatawebdataset connected to it and the I am able to retrieve the data
  • But fields which have connected to other tables are not showing up in the edit field. Like I want to show C001 or the Service code. Currently it is showing up as null. 

You have to add 

$expand=Customer_id,Service
to your request URL (see http://www.tmssoftware.biz/business/xdata/doc/web/expand.html).
This way the JSON will come expanded, and then in the XDataWebDataset you can simply add fields like Customer_id.id or Service.Name

I have tried doing what you have suggested.  I have two issues


This is the result I am getting from my query

My next issue is if I have to modify the Distribution_name which is shown as an object, How do I assign a new value to it ?

You have to create such field in the database. 

If you want to the dataset to create all subfields automatically, you can set SubPropsDepth to 1, see http://www.tmssoftware.biz/business/xdata/doc/web/using-txdatawebdataset.html
To change the distribution, you need to assign another JS object to the "Distribution_name" property.
Usually you would gather from the server a new object and simply assign the whole object to the field.

To RE-ASK Shah Rahul's question: My next issue is if I have to modify the Distribution_name which is shown as an object, How do I assign a new value to it ?


I've set TXDataWebDataset.SubpropsCount=1 and all subfields created OK. Now I wish to modify the object SYSTEMID value.

You have to replace it with a full object. Easiest way is to retrieve an object SYSTEMID from the server with ID 45, and then replace the field value.

You have to replace it with a full object. Easiest way is to retrieve an object SYSTEMID from the server with ID 45, and then replace the field value.  ???????????

Good morning Wagner;
Thank  you for your explanation, however, can you pretend that I don't know what you are talking about and actually show me how to do it?
Thank you.

Sure Steve, sorry about that.

Here is an example. I'm doing a server request asking for the Artist object with id 5.
When the request returns, I just put the retrieved value as the content of field "Artist".



  XDataWebClient1.Get('Artist', 5, procedure(Response: TXDataClientResponse)
    begin
      xdsAlbums.Edit;
      xdsAlbums.FieldByName('Artist').Value := Response.Result;
    end);