Hello
I am trying to create an experience builder app and I want to filter the widgets/ pages within this app based on the login. So, I will create two groups, and the members of each group will have a different view of the same app. Is that something I can achieve with Arcade/Javascript?
Good Question, Even i to want to know this workflow?
Hello @AbdulabnanMohammed ,
I used ChatGPT to find the answer,
use this arcade expression on your layer when adding it as a data source for the widget:
// Get the current user's username
var curr_user = GetUser()['username'];
// Create a feature set from the specified portal item
var fs = FeatureSetByPortalItem(
Portal("https://www.arcgis.com"),
"ITEM ID(Replce this part with the ITEM ID",
0, // Layer index
["*"], // Select all fields
false // Exclude geometry
);
// Filter the feature set by the current user's username
return Filter(fs, `Creator = '${curr_user}'`);