Retrieving 1:N related data in codeless

Hi,

I am following the example in this video to retrieve data from a secondary table.

I have 2 tables Retailers and Locations with a 1:N relationship pointing from Retailers to Locations.

I am displaying the name field in a button from Retailers and using this to run the relationship search and in the Locations I am trying to get data in the location field and display it as a list in a repeater block.

I have run the query in REST console and it works -

https://l…/api/data/retailers?where=%60name%60%20%3D%20’SOLAR’&loadRelations=locations

and the returned data looks like this -

[
	{
		"retailercat": 2,
		"created": 1737591408000,
		"name": "SOLAR",
		"___class": "retailers",
		"locations": [
			{
				"created": 1737590701000,
				"___class": "locations",
				"location": "Jackman City",
				"ownerId": null,
				"updated": null,
				"objectId": "29AAE884-D3D9-4D32-A19D-80A9B03510FA",
				"locid": 141
			},		
			{
				"created": 1737590701000,
				"___class": "locations",
				"location": "Banyard",
				"ownerId": null,
				"updated": null,
				"objectId": "3E017F52-CE04-4ABF-BE58-623DA0F9D379",
				"locid": 137
			},
			{
				"created": 1737590701000,
				"___class": "locations",
				"location": "Swindon",
				"ownerId": null,
				"updated": null,
				"objectId": "400C64CA-4172-4A45-AE88-124D414C4132",
				"locid": 86
			},				
		],
		"ownerId": null,
		"retailerid": 6,
		"updated": 1737655143327,
		"objectId": "67FE2B4D-73A4-44B7-8F06-F9519F465042"
	}
]

I have the Text block content set to locations.location but when I run the preview nothing happens.

In the console screen, I am verifying that the query is correct - name=‘SOLAR’.

2025-01-28 14 07 22

Would appreciate any assistance and also, what would be the correct terminator for the in list block to retrieve all of the records rather than first, last, etc.?

Thanks
Steve

Let’s take a closer look at the following logic:

What you have going on here is this:

  1. Retrieve a collection of retailers objects with the specified where clause and the related locations
  2. From the obtained collection, get the first item

The first item returned in (2) is actually an object representing a record from retailers. It is not a collection, it is the first object from the list.

If you need to get the locations property for that first object, you need to add additional logic that retrieves that property.

Hope this helps.

Mark

Hi Mark,

Thanks. I will work through to figure the additional logic. How do I though, get the list to retrieve all of the records as I mentioned that the options are only first, last, a particular number, etc.

Thanks

Are you talking about getting retailers records or locations for a specific retailer?

Hi,

Locations for a specific retailer.

Steve

Get the retailer object from the list and get the locations property from the object: