Check if a document field in dataset is empty

Hi Rachel:

undefined is a special value in javascript . It is the value you will get if a variable has not been initialised (i.e. to a value or null) or an object is missing the named property. Basically if the object property is not there then it is undefined :-).

The best way to test for this is to use the javascript Object helper function hasOwnProperty() Your code should work if it looks like this:

$w("#datasetISW").onReady(() => {
    let currentItem = $w('#datasetISW').getCurrentItem();
    // Add Eli's proposal
    console.log(currentItem);
    let hasDoc = currentItem.hasOwnProperty('cvURL');
    console.log("cvURL "+(hasDoc?"exists":"does not exist"));
    // Does the data set include a cvURL property for the current item?
    if (hasDoc) {             
            $w("#imgCV").show();
            $w("#txtCVUnavailable").hide();             console.log("document found");
    } else {
            $w("#txtCVUnavailable").show();             $w("#imgCV").hide();
            console.log("no document found");
    }
    console.log(hasDoc);
});

Cheers
Steve