Client API Mx.Data.Get with associated object two associations+ deep

1
I’ve been trying to emulate a datagrid retrieve through the Client API and hit an issue with retrieving data two associations deep. For example using the following code I can retrieve data for an account and the data on any associated managers: mx.data.get({ xpath: "//Administration.Account", filter: { sort: [["Name", "asc"]], offset: 0, amount: 1, references:{"Administration.Account_Manager":{}} }, callback: function(objs) { console.log(objs[0].getChildren("Administration.Account_Manager")[0].get("FullName")); } }); But if I try to replace the reference with one over multiple associations, say get a manager’s contact details it errors out: references:{"Administration.Account_Manager/Administration.Manager/Administration.Manager_Contacts":{}} Unfortunately the client API documentation doesn’t provide any example of the references property being used. Given that datagrids allow this sort of associations to be displayed, the API should allow the same access. Does anyone know how to do the retrieve?    
asked
2 answers
1

Just as an aside, if you take a look at the requests in the network inspector, you will find that the associated data is returned to a grid within a single request,  à la mode de vue de la base de données. Try find a grid with an associative column and check out the request body, you can test with curl

#!/usr/bin/bash
curl\
	"https://foo.bar.co.za/xas/"\
	-H "Accept: application/json"\
	-H "Accept-Language: en-US,en;q=0.5"\
	--compressed\
	-H "Content-Type: application/json"\
	-H "X-Csrf-Token: cff2bb51-6beb-4b41-b522-1b25371c73b3"\
	-H "Connection: keep-alive"\
	-H "Cookie: originURI=/login.html; XASSESSIONID=12345678-1234-1234-1234-123456789abc; xasid=0.12345678-1234-1234-1234-123456789abc; DeviceType=Desktop; Profile=Responsive" -H "TE: Trailers"\
	--data @exX.json|\
jq \
	'.mxobjects'

With exX.json with Schema as follows

{
  "action": "retrieve_by_xpath",
  "params": {
    "xpath": "//Foo.Bar",
    "schema": {
      "id": "12345678-1234-1234-1234-123456789abc",
      "offset": 0,
      "sort": [
        [
          "ApplLogDate",
          "desc"
        ]
      ],
      "amount": 20
    },
    "count": true
  },
  "profiledata": {
    "1567079664351-131": 331,
    "1567079701730-132": 21,
    "1567079704390-133": 27
  }
}

...or without, as follows

Note that without the id field specified in the schema, no associated data is returned. How does one get/generate the schema guid?

answered
1

Hi Dragos, 

Did you solved your problem eventually? I am having the same struggle, so maybe you can help me out by providing an example as Mendix does give us only the most easy ones...

Kind Regards,

Beyza

answered