Hi there,
I have moved to Agol from other services and I am having trouble with filtering. I have large datasets/maps that my technicians interact with, each feature is associated with a specific client. I serve interactive dashboards to these customers and they only see what features are filtered by their username/data. In other applications, this is a standard feature often called Row Level Security. I'm struggling with this on Agol, can I please get some advice on how to implement this; the mechanism, and most efficient approach ie. layer level, map level, dashboard, or experience?
Many thanks.
You can use a Data Expression in your dashboard, as that gives you access to user variables through the GetUser() function. You can use that to get the logged-in user's name, then apply different filters, etc., based on that value.
Hi there,
Would really appreciate some elabouration or ideally screenshots of exactly where and how you add the getuser function. Thanks
@JoeAbercrombie @jcarlson I haven't been able to implement this yet, either. I have a hosted feature layer, where one of the fields is the user that feature is assigned to. I want to be able to obtain the logged-in user with arcade and then filter the map/features to only the features they are assigned to.....
You can try something like this as your Data Expression
var fullname = GetUser()['fullName'] // alternatively change to ['username']
Console (fullname) // to check in the Console that the fullname is returned
var fs = FeatureSetByPortalItem( // get your feature service
Portal('https://www.arcgis.com'),
'itemid', //add in your itemid (e.g. '3385b003af5248e59c1fa68e1411c446')
2, // change to relevant layer id (e.g. 0)
['*'],
false
);
Console(Count(fs)) // to get number of features in feature service in Console
var filfs = Filter(fs, `AssignedUser= '${fullname}'`) // change field as needed
Console(Count(filfs)) // check in Console that it is returning the correct number of features assigned to the user
return filfs