How to call a dynamic dataset field on Velo?

Hi,
I have a Dynamic dataset
On the Title pages I have a video player (Youtube) that is connected to a url field on the dataset (the field is named youtubeLink .
I want hide the video player and show it only if the URL field is not empty.

I tried this code below, but the field key youtubeLink is not being recognized, I feel like I’m not writing the code correctly, maybe because it’s a dynamic dataset it should be set differently?

$w . onReady ( function () {
$w ( ‘#dynamicDataset’ ). onReady ( () => {
if ( $w ( ‘#youtubeLinkfield’ ). text === “” ) {
$w ( ‘#videoPlayer1’ ). hide ();
} else {
$w ( ‘#videoPlayer1’ ). show ();
}
} );
});

Hi Shirli,

Here is how to achieve this:

  1. In the url field in your collection, in the items where you don’t have videos add a dummy place holder url. something like: ’ http://placeholder.com

  2. In the code you need to use the getCurrentItem function to get the data and then check it looks something like this (videosrc is the name of the url field) :

$w . onReady ( function () {
$w ( ‘#dynamicDataset’ ). onReady (()=>{
let currentItem = $w ( ‘#dynamicDataset’ ). getCurrentItem ();
console . log ( currentItem )
if ( currentItem . videosrc === ‘http://placeholder.com’ ){

    $w ( '#videoPlayer1' ). hide (); 
} 

})
});

@idoh You’ve just made my day so much brighter!!!
Thanks so much, it worked! :grin:

@shirilipinsky Your Welcome, Glad I could help!