Using JavaScript to set advanced permissions in Geocortex Access Control

Using JavaScript to set advanced permissions in Geocortex Access Control

Ryan Cooney
Ryan Cooney
Product Owner
December 4, 2020

Using JavaScript to set advanced permissions in Geocortex Access Control

Using JavaScript to set advanced permissions in Geocortex Access Control

Geocortex Access Controls allows you to easily understand and control who has access to layers, fields, and features.

One of the ways this is configured is by using JavaScript to create your own business rules when you’re assigning permissions.

There are a few different ways to assign permissions. For starters, you can try using simple attribute filter rules where you’re assigning a given user, but if you’re faced with a more complicated scenario,  you can either do that business layer all within JavaScript, or you can send web requests to some other system that will do that for you.

Watch how this looks in the Geocortex Tech Tip below.

Watch on YouTube.

Video Transcript

“Hi, my name is Ryan, I’m going to show how you can use JavaScript to create your own business rules when you’re assigning permissions in Geocortex Access Control. Let’s have a look!

Today, I’ve got a bunch of point data for the State of Ohio. We can see each of these points has a county attribute, a couple of different counties here.

The business problem that I’d like to solve is that I would like a user from an individual county to only see the data for their accounting.

So, if I belong to Putnam County, I should only see the data in Putnam County here.

All right, so Access Control provides a really simple and easy way to do this, you select the service that you’re interested in, select the layer and define an attribute filter.

So, we can create a new attribute filter and assign it to either a user or group.

I’m just going to assign it to myself. This is the Geocortex demo account and I need to provide an attribute filter definition expression where clause.

In this case it would be “county equals” and I’m just going to put myself in Putnam County

So that’s defining the attribute filter. If I hit save, and refresh the application, there we go. I’m only seeing data in Putnam County.

So, it’s great, it’s easy and if I had a few other users in group to apply this to, no problem, I just follow that same pattern.

Now, what happens if there’s thousands of users? I don’t want to define thousands of these filters that would be pretty ridiculous. Usually the next stage would be we should be looking at using groups in the system.

If your organization already has properly organized groups or not properly, but relevant groups to the business problem that would be great. We could assign flip this over to User and I might select the Putnam County group and then just do the exact same thing as I’ve done here, that would be great.

There’s a couple problems with that one, there might be a lot of these things; Ohio’s got 88 Counties – I don’t really want to define 88 of these, but that would work. Sometimes the groups that might exist in your ArcGIS Enterprise don’t align at all with the business divisions that you might be trying to leverage here.

In that case we need another layer in between that can do that translation to say this user that either belongs either the username or they belong to a particular ArcGIS group well that’s really this business level group and that business level group has a where clause that should go with it.

So, this is where the power of advanced permissions comes in, so rather than doing one of these, I’m just going to eliminate that one and we’re going to go over to the advanced tab here.

So, when I create an advanced permission – it’s very similar, I can assign this permission to whoever I like.

This time rather than doing an individual one for a user or group, I can assign one for everybody and we’re going to have this one advanced permission take care of everything.

All right, so in here, we get to edit an expression and now we’re going to write some JavaScript,

So, don’t worry if you’re not too familiar with JavaScript we’re not going to write that much, but what we’re going to do is we’re going to write a short little script and this script is going to define a lookup for a given user. So, this script has access to the User in fact if I just start typing user that there is a user object here. We can use this user, we’ve got access to some things about that user we can get their name.

So given a username, let’s go and look up the county name that’s interesting for us.

What I’m going to do is I’m going to create an object called “lookup”.

So, it’s just a just a plain old object and it’s going to be the keys of this object will be the usernames and the values of this object will be the county they belong to. If “Geocortexdemo” is my username and the value or the county I’m going to put that in “PUTNAM”, and let’s do another one of these for a different user and we’ll put them in a different county; “ALLEN” County is right below Putnam County.

So, that’s my lookout this represents my business mapping of users to counties that doesn’t exist in any ArcGIS groups.

Now, I need to use that lookup to fetch a county and the way to do that is just to take that username and use it in the lookup.

So, we can take the username, use it to go and find the right key. Now is this username going to be uppercase lowercase? I’m not sure. Let’s just lowercase that to be safe.

All right, so now we have a county – or maybe we have a county – we’ve got a county if the user is one of these two users.

So if we have a county, now we can assign our where clause and the way to do that is to set an attribute filter and here we’re going to set the same sort of thing ‘county = ‘{county}’ to and I’m just going to use these template strings where I can inject the county.

So, we look up the county value, if it exists, we’re going to set an attribute filter that’s county is equal to the quoted county name.

If there wasn’t a county, we should handle the other case and we’ll just do the exact same thing we’ll set an attribute filter except rather than doing a real lookup, let’s just do your standard query to return nothing. So, if you couldn’t find you, you’re getting nothing if we could find you, you’re going to get exactly what your county offers. So hit ‘OK’, hit save, cross your fingers and refresh.

If I’ve done it right, we should see the exact same thing because I’m still in Putnam County, but to see that it’s actually working, let’s go over to this incognito tab where I’m signed in as the John Doe user. Previously, I could see everything, now I just get the Allen County values.

Okay, so what’s great about this is we’ve been able to use JavaScript to define our business logic that where there’s none of this exists in our ArcGIS groups.

So, rather than creating tons of groups or maybe your business logic just can’t be represented as simple groups, we now have a way to do that.

To complete this example, what we’ll be doing is filling in the list of these are all the users and the counties that they map to, you can get more sophisticated than this simple lookup, but that’s kind of up to you.

Another strategy could be you’ve actually got another system, another business system that can do this sort of look up for you.

Now I’ve created one here it’s a little web service. If I send it a username it returns the county and I’ll try this, John Doe. So, I get different values back, it’s actually a different county this time, but I could use this web service from my JavaScript.

All right, I’m just going to paste that one in rather than writing out the whole thing, but what we would do is this and I’ll walk through how it works.

So, we are going to run, so we’re just there’s a utility method to help us do asynchronous work.

We’ll make a web request that’s going to be asynchronous, we are going to use the fetch API, so it’s built in. We’re going to tell it the URL of our web service by passing the username as a parameter and we see we’re just going to encode it just to be safe.

So that username gets sent to this web service, so it’ll be issuing a request like this, it should be a JSON response that comes back.

So, assuming it was a successful response, we’ll go and get the JSON from that we will dig the county value out of that JSON.

You see there’s the county key that we’re after there. if the county exists, we’re going to set an attribute filter (this is identical to what we did before). At that point, we’re done we can just return and everything else falls through.

So, if we didn’t end up with a successful request or finding the right county, we’re going to set that “1=0” fallback, no data for you response, and I’m going to save that, refresh this one.

This should look the same again, as it does, and if I refresh this one, it should actually flip Counties because it’s not Allen county, it’s Hancock county. Now there it is!

It’s a fast demo of these advanced permissions, so we can see that we are able to filter data, this is spatial data, we’re filtering by attribute though, so we can filter data to users that belong to a given county, so they can only see their data.

There are simple ways to do it where you’ve just got a simple attribute filter rule where you’re assigning a given user, but if you’ve got a more complicated scenario than that,  where you need this sort of intermediate business layer, you can either do that business layer all in JavaScript or you can issue web requests to some other system that’s doing that for you and then you’re assigning these. So, we can get away with one permission that we’re defining that could now serve thousands of user groups, it keeps it really simple.

I hope this has been informative and I hope this is something that you could leverage to create your own business rules and start defining your own permissions!”

Want to see more of Geocortex Access Control in action? Click the button below for more product information, or to schedule a demo.

Discover Geocortex Access Control


Categories:
Archive
Open: 2020
2020
December 18, 2020

Configuring multiple charts in a band using Geocortex Inline [Geocortex Tech Tip]

December 4, 2020

Using JavaScript to set advanced permissions in Geocortex Access Control

November 27, 2020

Using SVG images in Geocortex Printing and Geocortex Reporting [Geocortex Tech Tip]

November 20, 2020

Integrating third party maps like Mapillary into Geocortex Web

November 13, 2020

Conditional Chart Symbology in Geocortex Inline [Geocortex Tech Tip]

November 6, 2020

Understanding permission inheritance in Geocortex Access Control [Geocortex Tech Tip]

October 30, 2020

How to use URL routing in Geocortex Printing [Geocortex Tech Tip]

October 23, 2020

Improving suggestions by using the Cast activity with Geocortex Workflow

October 16, 2020

Considerations when migrating from Geocortex Viewer for HTML5 to Geocortex Web [Geocortex Tech Tip]

October 9, 2020

Launching a report from Geocortex Inline [Geocortex Tech Tip]

October 2, 2020

How to include the current map image in a report [Geocortex Tech Tip]

September 25, 2020

Database monitoring in Geocortex Analytics [Geocortex Tech Tip]

September 18, 2020

Efficiently setting field permissions using advanced JavaScript permissions [Geocortex Tech Tip]

September 11, 2020

How to set different user and group permissions on fields and attributes in Geocortex Access Control [Geocortex Tech Tip]

September 4, 2020

Filter expression syntax and operators with Geocortex Access Control [Geocortex Tech Tip]

August 28, 2020

Leveraging attribute filters in Geocortex Access Control [Geocortex Tech Tip]

August 21, 2020

Using layer filter effects in Geocortex Web [Geocortex Tech Tip]

August 14, 2020

Conditional Tips in Geocortex Inline [Geocortex Tech Tip]

August 7, 2020

Configuring KPI cards in Geocortex Web [Geocortex Tech Tip]

July 31, 2020

Find your way around a workflow using the new Navigator component [Geocortex Tech Tip]

July 24, 2020

Working with symbols in Geocortex Workflow (Accessing JavaScript 3.x & 4.x playground etc) [Geocortex Tech Tip]

July 22, 2020

Simplify Pipeline Integrity Management with Geocortex Inline [Webinar]

July 17, 2020

Configuring Geocortex Web Events in Geocortex Web [Geocortex Tech Tip]

July 10, 2020

Creating and configuring launch links in Geocortex Mobile [Geocortex Tech Tip]

July 3, 2020

Using environment variables for application management in Geocortex Web and Geocortex Mobile Designer [Geocortex Tech Tip]

June 26, 2020

Understanding feature actions in the Geocortex Web and Geocortex Mobile Designers [Geocortex Tech Tip]

June 19, 2020

Geocortex Essentials import/export support enhancements in 4.13 [Geocortex Tech Tip]

June 12, 2020

Using Union Geometries in Geocortex Workflow [Geocortex Tech Tip]

June 5, 2020

Removing unneeded applications in Geocortex Web and Geocortex Mobile Designer [Geocortex Tech Tip]

May 29, 2020

A deeper dive on advanced View Designer configuration [Geocortex Tech Tip]

May 22, 2020

Launching a workflow in Geocortex Inline [Geocortex Tech Tip]

May 20, 2020

Geocortex Essentials 4.13: Additional development tools and external widget support let you customize your apps even further

May 15, 2020

Understanding points of interest and station locator [Geocortex Tech Tip]

May 8, 2020

Using the Inline Designer to build linear referencing views [Geocortex Tech Tip]

May 1, 2020

Understanding performance differences between Geocortex Workflow and the workflow capability in Geocortex Essentials [Geocortex Tech Tip]

April 24, 2020

Printing a vector tile layer in Geocortex Printing vs the Printing widget in Geocortex Essentials [Geocortex Tech Tip]

April 17, 2020

Producing layer reports in Geocortex Reporting vs the Reporting widget in Geocortex Essentials [Geocortex Tech Tip]

April 10, 2020

Comparing dynamic forms in Geocortex Workflow vs Geocortex Essentials [Geocortex Tech Tip]

April 7, 2020

Take control of your GIS with Geocortex Access Control [Webinar]

April 3, 2020

Performing field inspections with Geocortex Mobile (OOB Editing) [Geocortex Tech Tip]

March 27, 2020

Working with Conditional Expressions in Geocortex Reporting [Geocortex Tech Tip]

March 20, 2020

Export support and new third party map integration widgets [Geocortex Tech Tip]

March 13, 2020

Configure and Monitor a Web AppBuilder Web Application from Geocortex Analytics [Geocortex Tech Tip]

March 11, 2020

Geocortex Events and COVID-19/Coronavirus

March 6, 2020

Running a batch script from an alarm with Geocortex Analytics [Geocortex Tech Tip]

February 28, 2020

Understand how your users are engaging with the tools in your applications [Geocortex Tech Tip]

February 21, 2020

How to manage alarms in Geocortex Analytics [Geocortex Tech Tip]

Open: 2019
2019
December 18, 2019

Geocortex in 2019, and a glimpse of what's to come

December 5, 2019

Four key benefits to adopting a mobile GIS solution

November 29, 2019

Using Geocortex Mobile to collect survey data [Geocortex Tech Tip]

November 27, 2019

Dive into Geocortex Analytics [Webinar]

November 22, 2019

How to input parameters on prints [Geocortex Tech Tip]

November 15, 2019

How to include feature attachments in reports [Geocortex Tech Tip]

November 14, 2019

Understanding application management in the Designer [Geocortex Tech Tip]

November 14, 2019

How to reference symbology from web maps [Geocortex Tech Tip]

November 14, 2019

How Geocortex Mobile can integrate with other apps [Geocortex Tech Tip]

November 14, 2019

Implementing Arcade Expressions in Geocortex Essentials [Geocortex Tech Tip]

November 14, 2019

Customer Spotlight: Geocortex Mobile

November 14, 2019

How to Format Your Reports [Geocortex Tech Tip]

November 14, 2019

Showing an image in a form after a file picker [Geocortex Tech Tip]

November 14, 2019

Richard Wiegmann Joins VertiGIS as President and CEO

September 27, 2019

Understanding the toolbar in Geocortex Web [Geocortex Tech Tip]

September 20, 2019

Refining Results in Geocortex Web [Geocortex Tech Tip]

September 19, 2019

Charting data using Geocortex Reporting: Honing your charting skills

September 13, 2019

Utilizing the flexibility of layout in Geocortex Web [Geocortex Tech Tip]

September 6, 2019

Creating Geocortex Web applications that move seamlessly between 2D and 3D [Geocortex Tech Tip]

August 28, 2019

Geocortex adds support for Arcade scripting and ArcGIS Online smart mapping

August 23, 2019

How to create sections and groups for your reports [Geocortex Tech Tip]

August 16, 2019

Displaying SQL Server Data in Geocortex Workflow [Geocortex Tech Tip]

August 14, 2019

Customer Spotlight: Geocortex Essentials

August 8, 2019

City of Austin: Spreading floodplain awareness with Geocortex

August 1, 2019

Geocortex Essentials 4.12: Improved integration with ArcGIS® Online

July 25, 2019

Introduction to Geocortex Printing: Learn to build stunning print templates

July 17, 2019

Updates to the Geocortex Product Life Cycle

July 8, 2019

Extending Web AppBuilder for ArcGIS® with Geocortex Essentials [Webinar]

July 4, 2019

City of Bellingham: Using Geocortex to take the stress out of water shut-off

June 27, 2019

Geocortex at the 2019 Esri User Conference

June 14, 2019

Customer Spotlight: Geocortex Workflow

May 17, 2019

Important Notice - Outage Issues & New Support Cases

May 17, 2019

How to build a summary report with aggregations of feature data [Geocortex Tech Tip]

May 16, 2019

Technology Q&A: Geocortex Mobile

May 10, 2019

How to create print templates for Web AppBuilder for ArcGIS®[Geocortex Tech Tip]

May 8, 2019

Dive into Geocortex Printing [Webinar]

May 3, 2019

Using Geocortex Workflow and Geocortex Reporting to produce a multi-layer report [Geocortex Tech Tip]

May 1, 2019

Market-Leading GIS Software and Services Companies Join to Form VertiGIS

May 1, 2019

Introducing VertiGIS

April 18, 2019

Integrating Workflows into Geocortex Mobile [Geocortex Tech Tip]

April 17, 2019

Customer Spotlight: Geocortex Reporting

April 12, 2019

Using Geocortex Go to preview app configurations [Geocortex Tech Tip]

April 10, 2019

How to Address Complex Form Navigation Using Geocortex Workflow

April 5, 2019

Building native, offline IOS, Android and Windows apps with Geocortex Mobile Viewer [Geocortex Tech Tip]

April 3, 2019

Streamlining mobile operations with Geocortex Mobile Viewer [Webinar]

March 29, 2019

A better way to run geoprocessing tasks in Web AppBuilder for ArcGIS [Geocortex Tech Tip]

March 28, 2019

Extend the reach and capabilities of your applications with integrations [eBook]

March 22, 2019

Displaying data from SQL Database when you select features [Geocortex Tech Tip]

March 20, 2019

How Geocortex users are enriching the communities they serve

March 15, 2019

How to Configure a Geocortex Essentials layer report with Geocortex Reporting 5 [Geocortex Tech Tip]

March 14, 2019

Region of Waterloo: How GIS & Geocortex technology helped meet local Source Protection Plan requirements

March 6, 2019

Integrating Business Intelligence and Data Sources with Geocortex Essentials [Webinar]

March 1, 2019

How to quickly add attachments to new features when editing [Geocortex Tech Tip]

February 22, 2019

Generating a report with sub reports from external data sources [Geocortex Tech Tip]

February 20, 2019

Geocortex Essentials 4.11: Saving Time & Increasing Efficiency

February 15, 2019

Accessing Samples and Building your First Workflow [Geocortex Tech Tip]

February 12, 2019

Open Beta of Geocortex Printing 5 Has Begun

February 8, 2019

Different Ways of Creating Selections of Features in Geocortex Viewer for HTML 5 [Geocortex Tech Tip]

February 6, 2019

4 Best Practices to Follow When Using Geocortex Workflow 5

February 1, 2019

Creating a Report that Displays a Screenshot of the Map [Geocortex Tech Tip]

January 28, 2019

Diving Into Geocortex Reporting 5 [Geocortex Tech Tip]

January 24, 2019

How Geocortex is Advancing Water Management Solutions

January 16, 2019

Creating Custom User Experiences with Geocortex Workflow 5 [Webinar]

January 11, 2019

Showing the search results using the item picker in Geocortex Workflow 5 [Geocortex Tech Tip]

January 9, 2019

City of Troy: Using GIS and asset management technologies to manage legislative requirements

January 4, 2019

Using scripting to put attachments in reports in Geocortex Reporting 5 [Geocortex Tech Tip]

Open: 2018
2018
December 21, 2018

Integrating Pictometry, Bing and other 3rd party maps within your Geocortex applications

December 19, 2018

Recapping the Texas Geocortex Regional User Group

December 14, 2018

How to use Geocortex Workflow 5 to populate the Attribute Table in Web AppBuilder for ArcGIS [Geocortex Tech Tip]

December 12, 2018

Finding yourself: Using geolocation in mobile and web applications [Webinar]

December 7, 2018

Enabling real-time user-to-user map collaboration within Geocortex Essentials

December 5, 2018

Reflecting on 2018

November 30, 2018

Creating mailing labels with reports with Geocortex Reporting 5 [Geocortex Tech Tip]

November 29, 2018

Alberta Energy Regulator: Supporting safe and responsible energy resource operations

November 26, 2018

Important update for ArcGIS and Transport Layer Security (TLS) Protocol Support!

November 23, 2018

Using fine-grained security to control access to layers, features, attributes and application functionality [Geocortex Tech Tip]

November 21, 2018

Enhancing Web AppBuilder for ArcGIS® with Geocortex Reporting [Webinar]

November 16, 2018

Using Geocortex Workflow 5 to automatically display a form for editing layer attributes [Geocortex Tech Tip]

November 15, 2018

Geocortex Achieves Esri’s “Release Ready Specialty” Designation

November 14, 2018

Celebrating GIS Day with York Regional Police: How GIS Data Has Mitigated Risk & Increased Efficiency in Crime Prevention

November 9, 2018

How to access a SQL database from a workflow using Geocortex Workflow 5 [Geocortex Tech Tip]

November 2, 2018

How to send an email from a workflow using Geocortex Workflow 5 [Geocortex Tech Tip]

October 26, 2018

How to add and configure charts inside reports with Geocortex Reporting 5 [Geocortex Tech Tip]

October 24, 2018

Geocortex Water Webinar Series

October 19, 2018

Integrating Geocortex Essentials with ArcGIS Online and ArcGIS Enterprise portal [Geocortex Tech Tip]

October 17, 2018

Cross-Platform Development with Xamarin [Webinar]

October 12, 2018

City of Fort Collins: Dynamic flood maps for public awareness, and flood insurance rate saving

October 2, 2018

Technology Q&A: Geocortex Workflow 5 “Behind the Firewall”

June 27, 2018

Geocortex Essentials 4.10 is here!

June 12, 2018

Geocortex and the GDPR

June 6, 2018

Geocortex at the 2018 Esri User Conference

May 15, 2018

Technology Q&A: The evolution of Geocortex and Web AppBuilder for ArcGIS

April 25, 2018

How to manage data collected from Geocortex Workflow 5 forms [Geocortex Tech Tip]

April 18, 2018

Delivering accessible mapping applications for everyone [Geocortex Tech Tip]

April 11, 2018

How to search for data in a non-spatial database [Geocortex Tech Tip]

April 5, 2018

Configuring Geocortex Analytics to monitor a new Portal for ArcGIS instance [Geocortex Tech Tip]

March 27, 2018

Getting started with forms in Geocortex Workflow 5 [Geocortex Tech Tip]

March 21, 2018

Using Geocortex Workflow with Web AppBuilder for ArcGIS [Geocortex Tech Tip]

March 15, 2018

Understanding tool usage in your GIS applications [Geocortex Tech Tip]

March 7, 2018

Running Geocortex Essentials workflows from an identify operation [Geocortex Tech Tip]

March 2, 2018

GIS Health Assessment: A new way to think about your system

February 28, 2018

Using the in-app help system in Geocortex Workflow 5 [Geocortex Tech Tip]

February 21, 2018

How to configure a personalized dashboard in Geocortex Analytics [Geocortex Tech Tip]

January 25, 2018

GIS is shifting to SaaS, and it’s a win for everyone


Categories

Popular Tags
Access Control Accessibility Active Operating Picture ArcGIS customer spotlight Customer Story Designer Energy Esri Geocortex Geocortex 5-Series Geocortex Access Control Geocortex Analytics Geocortex Essentials Geocortex Inline geocortex integrations geocortex item manager geocortex mobile Geocortex Mobile Viewer geocortex printing Geocortex Reporting Geocortex Reporting 5 geocortex tech tip Geocortex Tech Tips geocortex training Geocortex Viewer for HTML5 geocortex web Geocortex Web Viewer Geocortex Workflow Geocortex Workflow 5 GIS GIS Day GIS Health Integrations mobile gis Pipelines Tech Tip Tech Tips Tip Tips vertigis Web AppBuilder Web GIS Workflow Xamarin

Contributors