@jonatandor35 I made the change and still no luck! I’m testing with a user that has several roles, but the repeater shows all roles instead of being filtered, and the code doesn’t move beyond the “let relevantValues = roles.map” line.
When I test on a user with no roles, the “if (r.length > 0) … else” works as expected to show the elements I want it to.
import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
let user = wixUsers.currentUser;
$w.onReady(function () {
$w('#stripLoading').expand();
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: "nc1" },
] //etc
console.log("roles defined");
let filter = wixData.filter();
console.log("let filter");
let roles = r.name;
console.log("let roles");
let relevantValues = roles.map(e => roleValues.find(i => i.role === e).value); // still gets stuck around here, because the below console messages never appear
console.log("please work this time");
filter = filter.eq("roleFilter", relevantValues[0]);
console.log("filter log 1");
relevantValues.shift();
if (relevantValues.length > 0) {
relevantValues.forEach(e => {
filter = filter.or(wixData.filter().eq("roleFilter", e));
})
console.log("filter log 2");
}
$w("#ocDataset").setFilter(filter).then(() => {
console.log("filtered");
ordersView();
})
} else {
noOrdersView();
}
})
}
})
