Filter Data and Chart based on Login

1770
14
Jump to solution
02-28-2023 11:56 PM
MuhammadNaufalIhsan
New Contributor III

Hi,

Is there anyway to filter data and chart in dashboard (or experience builder) based on the user login? The idea is when user A login, the dashboard will only shown the user A data and he/she will not be able to see the data created by other user. The rule will be also applied to charts or widgets related to the data.

Regards,

Naufal

14 Replies
PaulPetersen1
Occasional Contributor

Hi @Nicole_Ueberschär , just a little bit after making my first post, we figured out how to get it to work. Turns out that the getUser() function was somehow causing the issue (even though the Test would work). After tweaking the function a bit, it now works. See below. 

 

var port = Portal('https://xxxx.com/portal');
var fs = FeatureSetByPortalItem(
    port,
    'xxxxxxxxxxxxxxxxxx',
    0,
    [
        'Inspector'
    ],
    false
);
Console(Count(fs)) // to get number of features in feature service in Console
 
var u = getUser(port);
var fullName = u.username;
Console (fullname) // to check in the Console that the fullname is returned
 
var filfs = Filter(fs, `Inspector= '${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

 

Nicole_Ueberschär
Esri Regular Contributor

Thanks a lot for this @PaulPetersen1 ! What difference the case of a letter can make! 😲

Any idea what to do about the map content?

0 Kudos
PaulPetersen1
Occasional Contributor

@Nicole_Ueberschär , no not sure about the map content. If you don't have tons of users or groups, you could perhaps try something with hosted views with separate group permissions and filters...handle it there rather than in the dashboard. I've also had success in solving "filter puzzles" by using the NOT operator rather than Equals and coming at things from the opposite angle. Probably not helpful for your situation.

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

Thanks @PaulPetersen1 , we managed to do it using the url parameter option from the dashboard and then embed it into an application in which we use javascript to create the url based on the signed in user.

Now I am having the same problem with limiting the content in a Web Appbuilder application. Any idea ? Using views is just not feasible for 30+ users 😞

0 Kudos
PaulPetersen1
Occasional Contributor

@Nicole_Ueberschär , glad you got it going with URL parameters. No, I don't have any experience with Web App Builder, when it comes to limiting content. You may look into whether it can support URL parameters as well, or see if shifting to Experience Builder is viable.

0 Kudos