Hi All,
I have table on Dynamic page. I want data to be filtered based on logged in User's email id. I have dome following code: I have tried both '#dataset1' as well as '#dynamicDataset' but it doesn't work. I am getting all the records in table
$w.onReady(function () { let userEmail = wixUsers.currentUser.getEmail() currentUser.getEmail() .then( (email) => { userEmail = email; console.log(userEmail); console.log(' OR before count'+ count); $w("#dynamicDataset").setFilter(wixData.filter() .eq("email", userEmail) ).catch((err) => { console.log('in error' + err); }) count = $w("#dynamicDataset").getTotalCount(); console.log(' OR after count'+ count); }) })
@Piush Goyal Looking at the code more closely, I'm not seeing where you are declaring the variable count before you use it in the console.log. That would result in a reference error that would halt the execution of the filtering code that comes after it.
So you know, it's forum policy to put code in a code snippet block. It will allow for the easy copying and pasting by someone responding to your post.
Thanks. I tried this as well but nothing happens.
$w.onReady(function () { $w("#dynamicDataset").onReady( () => { let userEmail = wixUsers.currentUser.getEmail() currentUser.getEmail() .then( (email) => { userEmail = email; console.log(userEmail); console.log(' OR before count'+ count); $w("#dynamicDataset").setFilter(wixData.filter() .eq("email", userEmail) ).catch((err) => { console.log('in error' + err); }) count = $w("#dynamicDataset").getTotalCount(); console.log(' OR after count'+ count); }) }) })
@Piush Goyal The problem is that the dataset is not yet ready to access. Using an onReady function on the dataset will solve that:
$w.onReady( () => { $w("#dynamicDataset").onReady( () => { // all your code ... } ); } );