Select to view content in your preferred language

Filter widgets/ Pages based on login

491
2
08-25-2024 12:11 AM
Labels (1)
AJD
by
Occasional Contributor

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?

2 Replies
AbdulabnanMohammed
Occasional Contributor

Good Question, Even i to want to know this workflow?

0 Kudos
AJD
by
Occasional Contributor

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}'`);

0 Kudos