Get Data from Collection Field (Hyphen Issue)

Dear All,

I created a collection listing my Members connected to a Dynamic page.

On another page I have a Repeater, a Dropdown (Members) and two TextBox (Member Nickname) & (Member URL).

I need to get the (Member Nickname) & (Member URL) and dispatch the data to the TextBox.

For that I use the following code:

export function DropdownMember_change(event) {
	let $item = $w.at(event.context);
	wixData.get("Members", $item('#DropdownMember').value)
		.then((results) => {
			let item = results; //see item below
			$item('#TextMemberNickname').text = results.nickname
			$item('#TextMemberURL').text = results.link-members-title
		})
}

For the (Member Nickname) is OK but I have problem with the (Member URL), field created by the Dynamic page. I have issue because the “Field Key” contains hyphens.

What is the solution?

Thank you very much for your help.
Best regards,
Domivax

Hi :raised_hand_with_fingers_splayed:

You need to access it like this

.then((item) => {
    $item('#TextMemberNickname').text item.nickname;
    $item('#TextMemberURL').text = item['link-members-title'];
})

Replace you then section with mine then you’re good to go.

Hope that helped~!
Ahmad

Thank you my Dear Ahmad,

It is working perfectly.

Best regards,
Xavier

My final code:

export function DropdownMember_change(event) {
	let $item = $w.at(event.context);
	wixData.get("Members", $item('#DropdownMember').value)
		.then((results) => {
			let item = results; //see item below
			$item('#TextMemberNickname').text = results.nickname
			$item('#TextMemberURL').text = results['link-members-title'];
		})
}

You’re welcome :wink: