I am trying to query a reference field to populate a repeater and I am having some difficulty. This is what I have found online so far but it’s not working.
function userDefinedFields () {
$w( ‘#dbApplications’ ).onReady(() => {
$w( ‘#rptApplications’ ).onItemReady( async ($w, itemData, index) => {
let description = itemData.jobRef;
const resDescription = await find_description_info
$w( ‘#txtDescription’ ).html = resDescription.substring( 0 , 150 ) + “. . .” ;
let closingDate = itemData.jobRef;
const resDate = await find_date_info
var options = {day: “numeric” , month: “long” , year: “numeric” };
var daysRemaining = Math.round( (itemData.closingDate - Date.now()) / 1000 / 60 / 60 / 24 )
$w( ‘#txtClosingDate’ ).text = resDate.toLocaleDateString( “en-GB” , options)+ " (" + daysRemaining + " days remaining) " ;
});
});
}
function find_description_info(event) {
return wixData.query( “Applications” )
.eq( “description” , jobRef)
.find()
.then((res) => {
return (res.items[ 0 ].description)
})
}
function find_date_info(event) {
return wixData.query( “Applications” )
.eq( “closingDate” , jobRef)
.find()
.then((res) => {
return (res.items[ 0 ].closingDate)
})
}