I retrieve data from a collection. But if the Information retrieved from the collection equals a value I want it to do something
title is the field name in the collection. How can I use the field name in an IF Condition?
export function dropdown2_change_1(event, $w) { $w('#columnStrip2').hide() wixData.query('Documents') .eq('applicationText', $w("#dropdown2").value) .find() .valueOf() .then(res => { if (title === '1000') { wixLocation.to('url') } else { $w('#text20').show(); $w('#table2').rows = res.items; $w('#table2').show(); } }); }
First of all you get more than one item so you can't set conditions on all, you must enter the one specific record you want to check like:
if (res.items[0].title === '1000') {
That will take the first item of the items array which contains all the results that your query returns. makes sense?