I have a repeater connected to a dataset that has several reference fields. I can access these reference fields just fine by clicking “connect to data” in the editor, but I want to concatenate text onto the reference field data that I pull, so I wrote the following function that is called by the onItemReady handler of the repeater:
export function ordersRepeater_itemReady ( $item , itemData , index ) {
populateRepeaterFields ( itemData , $item );
}
function populateRepeaterFields ( itemData , $item ) {
$item ( “#sizeText” ). text = ${ itemData . product . size } yd Bin
;
$item ( “#durationText” ). text = ${ itemData . product . daysIncluded } days
;
}
These show up as ‘undefined’, and when I log the ‘itemData.product’ it only shows the id of the reference, not the object (i.e. the referenced object isn’t included in the data array that populates the repeater).
However, if I connect an element to one of the reference fields manually, the code works (so apparently the referenced object is now included in the query that populates the repeater data array).
This is a bit of a janky solution - maybe include an option in the “Connect to Data” button on the repeater that lets you specify whether to include reference fields?
I realize this is not a large issue but it stumped me for a while on multiple occasions. The API and the docs don’t really show how the data array is queried for the repeater as far as I can tell so it took some mashing to figure out what was going on.