Custom Web Tool in MapViewer - for ArcGIS Online Administrative Tasks (delete users)

362
0
3 weeks ago
BrianBaldwin
Esri Regular Contributor
5 0 362

The last release of ArcGIS Online included the ability to publish 'Custom Web Tools' that could be used in the MapViewer analysis pane. What this means, is that users can utilize the ArcPY and ArcGIS API for Python libraries from within MapViewer.

The aspect of this that I think is pretty awesome - is that you don't need to utilize this functionality with any map content... it could be used to grant administraive tasks/duties to users within a simple to use UI.

Recently - I have heard from a number of users that are looking for easier ways to manage the deletion of users. There have been some fantastic enhancements in the UI that allow for this, but many users want some more fine-grained control over 'how' to select users for removal. So... let's create a Custom Web Tool!

In the MapViewer - I now have a basic tool that let's me query for the 'Number of Days' since users have logged in, query for a specific user name, and also transfer their content over to someone else.

BrianBaldwin_0-1724084960246.png

 

Watch a full video of the workflow... or skip ahead!

 

Let's Delete Some Users!

The initial script for this Web Tool came from this Esri Support document: https://support.esri.com/en-us/knowledge-base/batch-remove-inactive-users-in-portal-for-arcgis-using...

If you would like to start with my Notebook - you can find that here as well: https://arcgis.com/home/item.html?id=287ebf9a7724405884b83d1fc96f04cb 

Be aware... this script WILL delete users that match the query! So please, test cautiously! This was part of the reason that I entered in a 'hard coded' user name to test with. Obviously, you can delete multiple users at a time, but make sure you understand what you are querying for!

Let's get started...

After I imported the script into the ArcGIS Notebook, I then created parameters:

BrianBaldwin_0-1724083372207.png

 

I then made sure to update my script with the variable values for the parameters that were created:

BrianBaldwin_1-1724083466434.png

 

Lastly - I selected 'Publish' to create a web tool from the notebook. This will now appear as an item in My Content and I can adjust the sharing just as I would any other item.

There are a wide-range of other ways that you can query for users as well. Please refer to the full ArcGIS API for Python documentation to see what other values you could use for your script: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user 

Over to MapViewer!

Within MapViewer - it's as simple as going to the Analysis pane, and then selecting the new 'Browse custom web tools' option:

BrianBaldwin_2-1724083983274.png

 

The UI is then populated with the parameters and values from your custom web tool - and you are ready to run it!

BrianBaldwin_3-1724084032710.png

 

Close

I can't wait to see some of the amazing web tools that people end up building out. The ability to leverage the ArcPy and ArcGIS Python API libraries within MapViewer opens up a HUGE amount of possibilities for both rich analysis and... ArcGIS Online administrative tasks.

If you make something awesome, don't forget to share it and please let me know about it here!

 

 

About the Author
Brian works as a Lead Engineer at Esri to support customers in Education. Brian has worked as a lecturer in GIS, supported non-profits through his community planning work, and honestly just loves working with users to help solve their geospatial quandaries!