Select to view content in your preferred language

data expressions to filter a feature layer

767
6
Jump to solution
01-31-2025 03:24 AM
Labels (2)
Davide_Pili
Occasional Contributor

Hello everyone,

I’m working on a dashboard and I’d like to create an automatic filter based on the username of the user who accesses it. The filter should be applied to a field different from 'Creator'. Let me clarify: a user accessing the dashboard should only see the records related to their company, but these records were created by a different account, so I can’t use the Feature Layer settings. I was thinking of using a data expression with a filter based on the user.

Is a data expression a possible solution? Do you have any examples or guidance to share? Alternatively, how could I approach this?

Thank you!

 

 

 

0 Kudos
1 Solution

Accepted Solutions
JenniferAcunto
Esri Regular Contributor

You can create a view that does the current user filtering for you and then build your dashboard off of that view. 
Display Features Relevant to the Current User

- Jen

View solution in original post

6 Replies
MobiusSnake
MVP Regular Contributor

I haven't done this (nor am I certain it's possible), but if commercial sensitivity is crucial I'd recommend using hosted feature layer views and separate dashboards for each company rather than a dynamic filter in a dashboard.  Using filters at map/app levels means users can still access the feature layers at the service level and bypass those filters.

0 Kudos
Davide_Pili
Occasional Contributor

This is absolutely true. Normally, I would work with separate views and dashboards, but in this case, I have agricultural companies from the entire region—potentially exceeding 5,000 units—which is unfeasible. That's why I'm looking for a dynamic filter. I need data cleanliness on the map more than ensuring that users see all the data from the FL.

0 Kudos
RPGIS
by MVP Regular Contributor
MVP Regular Contributor

Hi @Davide_Pili ,

It might be possible, and probably far fetched, but you might be able to use arcade to get the username and create a custom set of features within the dashboard as an extra dataset.

Portal functions | ArcGIS Arcade | Esri Developer

Davide_Pili
Occasional Contributor

Thanks @RPGIS 

I had already tested this approach, but I couldn't get it to work. The solution that follows was faster and worked right away.

Thanks anyway

0 Kudos
JenniferAcunto
Esri Regular Contributor

You can create a view that does the current user filtering for you and then build your dashboard off of that view. 
Display Features Relevant to the Current User

- Jen
Davide_Pili
Occasional Contributor

Thanks @JenniferAcunto 

it works. that's what I was looking for.
Very quick and easy procedure.

Thanks again

0 Kudos