Filtering dataset to show user-specific text fields

Hi all,

Am trying to show a user specific info (that I would be changing from time to time) in a text field (not a repeater and not a table). Was thinking of filtering by the user’s email. But I can’t seem to filter it. I tried to use wixData.query and then setFilter or can I just use setFilter but both codes are not working. Please see both codes below… Am I doing something wrong?

function emailFilter() {
let user = wixUsers.currentUser;
let email = user.getEmail()
let userEmail = email;
wixData.query(“Targets”)
.eq(“email”, email)
.find()
.then(() => {
$w(“#datasetPlan”).setFilter(wixData.filter()
.eq(“FTarget”, $w(‘#FTarget’).text)
)
.then(() => {
console.log(“Dataset is filtered”);
})
. catch ((err) => {
console.log(err);
});
});
}

function emailFilter() {
wixUsers.currentUser.getEmail()
.then((email) => {
console.log(email, ‘email sent to filter’)
$w(“#datasetPlan”).setFilter(wixData.filter()
.eq(“email”, email)
)
.then(() => {
console.log(email);
})
. catch ((err) => {
console.log(err);
});

thanks!!

Is it a “Dynamic Page” ?
When yes, you don’t need to code a single line.

@benibrodi I didn’t do a dynamic page. If i don’t want to use a dynamic page, is there another way?