@jonatandor35 Hey thanks so much again for your patience and assistance.
I made the changes and it’s still not filtering the repeater ![]()
I get a slightly different error in the console, and now the code seems to stop where we added the new line:
Things I’ve done:
Changing the roleFilter field in the database to Text instead of Tags
Checking the permissions on the dataset
Double-checking that all IDs, role names, and field values are exact
Testing on a user with several combinations of multiple roles, multiple times
Including all roles in the roleValues array
The latest code:
$w.onReady(function () {
$w('#stripLoading').expand();
$w('#repeaterStrip').collapse();
if (user.loggedIn) {
user.getRoles()
.then(r => {
if (r.length > 0) {
let roleValues = [
{role: "EXP Treasure Box", value: "expTB" },
{role: "EXP Treasure Box", value: "expMM" },
{role: "ncGrade1", value: "nc" },
{role: "PrinciplesExcellence", value: "poe" },
] //etc
console.log("roles defined");
let filter = wixData.filter();
console.log("let filter");
let roles = roles.map(e => e.name);
roles = roles.filter(e => roleValues.some(i => i.role === e));
console.log("let roles");
let relevantValues = roles.map(e => roleValues.find(i => i.role === e).value);
console.log("let relevant values");
filter = filter.eq("roleFilter", relevantValues[0]);
relevantValues.shift();
if (relevantValues.length > 0) {
relevantValues.forEach(e => {
filter = filter.or(wixData.filter().eq("roleFilter", e));
})
}
$w("#ocDataset").setFilter(filter).then(() => {
console.log("Dataset is now filtered");
ordersView();
})
} else {
noOrdersView();
}
})
}
})
