Filter a list element based on logged in user

1769
8
Jump to solution
07-08-2022 10:01 AM
Becca_Settele
New Contributor II

Hi,

I'm trying to create a list element in a dashboard where it filters out the records created by the logged in user. The data for this list element is a related table that is the result of staff entering in project reviews (called staffinput). My end goal is a list element that only shows the project reviews they submitted in the embedded survey123 form in the dashboard. 

I've got the first part of the data expression where I use FeatureSetByPortalItem to locate the table but can't quite figure out how to filter this staffinput table based on the user that is logged in. I thought a filter statement would do the trick, but I'm realizing I'm not sure how the expression will recognize which created user is logged in. 

Is this even possible in dashboards?

Here is a snip of the data expression below:

Becca_Settele_1-1657299592317.png

 

 

1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It's actually very simple. We use this functionality ourselves, for a very similar process. In Arcade, the function is called GetUser. It returns a dict, so you'll need to pull out the username from that.

var curr_user = GetUser(portal)['username']

var fsFiltered = Filter(fs, 'created_user = @curr_user')
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
8 Replies
jcarlson
MVP Esteemed Contributor

It's actually very simple. We use this functionality ourselves, for a very similar process. In Arcade, the function is called GetUser. It returns a dict, so you'll need to pull out the username from that.

var curr_user = GetUser(portal)['username']

var fsFiltered = Filter(fs, 'created_user = @curr_user')
- Josh Carlson
Kendall County GIS
0 Kudos
Morgan22
New Contributor

This is exactly what we need as well, but I am not quite following the workflow. 

We have an expense report survey that is filled out by particular staff, then it goes to a "rejected/approved" monitoring dashboard operated by finance, who change its status to approved or rejected in another survey form feeding the same feature layer through a shared url. 

We want our staff to then only see their own expense reports when they log in to the next dashboard. We have tried applying the filter to the list but are not sure what is meant by the table of "created_user" in the solution you posted. 

It would really sort us out to get this right. we tried replacing this with "creator" or user name but still have not had any luck. 

do you have any suggestions? 

Thank you for your help. 

 

0 Kudos
Morgan22
New Contributor

Morgan22_1-1701406614998.png

 

0 Kudos
Becca_Settele
New Contributor II

Thank you @Josh!!! This is exactly what I was looking for. Works great!

0 Kudos
Jaivik_P
New Contributor III

@Becca_Settele we are trying to implement similar solution for Dashboard - filtering survey that was submitted by signed in user.

Would you please share how were you able to apply that expression in Dashboard? I dont see any way of supplying that kind of expression (when I say that my apologies if I am not aware of the possibility - just starting with creating dashboard solutions).

0 Kudos
Becca_Settele
New Contributor II

What element in your Dashboard are are you looking to filter? I was able to use Josh's GetUser statement and filter function above to filter a list element and indicator widget in my Dashboard to only show projects that are assigned to the logged in user. 

0 Kudos
Jaivik_P
New Contributor III

Hi @Becca_Settele,

Thanks for your response.

I am also looking for filtering 'List' element in dashboard that filters value in the list based on a signed in user. Actually to apply the function, I didnt find an Advanced Formatting option in List element.

After little bit of research, I realized that the 'Advanced Formatting' is available in Dashboard starting from ArcGIS Enterprise 10.9.1 version. We are currently at 10.8.1 and that's the reason I don't see that functionality. 

 

image.png

 

Jaivik

0 Kudos
Becca_Settele
New Contributor II

Hi @Jaivik_P, ah yes it looks like you need to have the latest version of dashboards to get those advanced formatting and data expressions options. Once you have that, you can add a list element and select a new data expression as the source. That's where I used that code to filter that data set by the logged in user. Feel free to send me a note if you're having issues with that once you get the latest dashboard update. 

Becca