1

We have Arcgis Portal 10.7.1 set up with WebAppbuilder 2.51 Users sign in using their Enterprise logins. We also have a large Feature Service dataset (over 1 million records) with multiple account managers and one of the fields contains their login usernames.

We were trying to implement a way to be able to pull their portal usernames into possibly the filter Widget and filter the dataset based on which user is logged in.

I already did a search of StackExchange and found this article, but we could not implement it to function properly. Use single sign-on username in Web AppBuilder filter widget?

I was hoping that someone else has run into this and implemented a possible solution, even if it is not using the Filter widget.

To be specific, I am getting the error when implementing the code in the link above, and receiving this error, although I followed all the instructions.

Cannot read property 'getPortal' of undefined

1 Answer 1

2

I got this working by basically putting all the code in the _getExpr: section of the Filter Widget.

_getExpr: function(layerId,username) {
        //var portal = new esri.arcgis.Portal('https://segramapsdev.lumosnet.com/portal/')
        //var userName = esri.arcgis.PortalUser(this.username);

        this.portal = portalUtils.getPortal(this.appConfig.portalUrl);  
        username = this.portal.user.username;  

         if (!this._store[layerId]) {
          return null;
        }

        var parts = [];
        var exprs = this._store[layerId];

        for (var p in exprs) {
          var expr = exprs[p];
          if(expr.toString().indexOf('*USERNAME*') !== -1)
            {
            expr = expr.replace('*USERNAME*', username);
            }
          if (expr && p !== 'mapFilterControls') {
            parts.push('(' + expr + ')');           
          }

        }
1
  • Where is the Filter Widget code located (folder/path location) in order to make this edit?
    – cm1
    Commented Feb 23 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.