Getting value from system autogenerated field with a dash

Hi there,

I’m trying to populate data collection into a repeater. Everything works fine, except for the link. Field name is ‘link-artists-title’, and I’m using the following code:
$w( “#repeater1” ).onItemReady( ($item, itemData, index) => {
$item( “#image1” ).src = itemData.mainImage;
$item( “#text28” ).text = itemData.artType;
$item( “#text25” ).text = itemData.title;
$item( “#text27” ).text = itemData.genre;
$item( “#text26” ).text = itemData.shortDescription;
$item( “#button2” ).link = itemData.link-artists-title;

} );

Problematic line is: $item( " #button2 " ).link = itemData.link-artists-title;
The problem seems to be the dash in the fieldkey.

I was trying also: $item( " #button2 " ).link = itemData[‘link-artists-title’];
But no luck!

Thank you for your help!!

Your second option should work OK:

$item("#button2").link = itemData['link-artists-title'];

Since you’re trying to set the .link property of a button, are you sure that the link is in the proper format?

Also, are you sure that you have content in that field?

You can inspect the contents of itemData by adding this line to the onItemReady() function:

console.log(itemData);