Esri / field-maps-scripts

A set of scripts and notebooks to help administer maps and workflows for ArcGIS Field Maps.
Apache License 2.0
59 stars 14 forks source link

Bulk update map typekeywords for use in Field Apps #7

Closed niravi closed 3 years ago

tschwartzman commented 3 years ago

A few comments/issues:

Minor: you can easily put a search in that returns web maps that you have access to but don’t own and cannot update (e.g. leave out the owner part of the search and not be an adminstrator, which will return things shared with you via groups/org but you don't have permissions to update). The script will fail when trying to write typeKeywords to these items. Might want a try/except or something in there(?) for the update.

Major: Collector status has 3 states with respect to the typeKeywords: • “Collector” keyword is present- webmap is collector-ready, i.e. it has editable layers in it and thus can be changed to CollectorDIsabled • “CollectorDisabled” keyword is present: webmap is collector-ready but disabled, but can be changed to be enabled • Neither of the above keywords are present, and thus it is not “collector-ready” and no keyword changes should take place

The stripped down script does not deal with that tri-state possibility and could add “Collector” or “CollectorDisabled” to a web map that normally is not available in collector. (that is what turns the UI “checkbox” on, presence of Collector/CollectorDisabled, but these items do not (should not) even show a checkbox)

tschwartzman commented 3 years ago

a few comments:

  1. (near the top) gis=GIS(“home”) works in Pro’s notebook environment as well, so you might change your comment on that line to reflect hosted or pro notebooks

  2. If I do a query for web maps that does not explicitly query for collector/collectordisabled keywords, I can still be adding a Collector/CollectorDisabled keyword where I shouldn’t.

Example:

collector_usage=”enabled” webmap_search_query=”Hydrant”

Let’s say that returns 1 web map, but it is not collector-ready, meaning it has no editable layers in it, and neither of the Collector/CollectorDisabled typeKeywords are present.

I believe your code will add “Collector” to the typeKeywords, which will be bad, since it will add the UI checkbox and actually let it show up in collector when it should not.

Could add a ‘collectorReady’ flag e.g.

collectorReady = ‘Collector’ in current_keywords or ‘CollectorDisabled’ in current_keywords

and then your assignments are something like:

if collector_usage == ‘enabled’ and collectorReady: discard, add elif collector_usage == ‘disabled’ and collectorReady: discard, add

(but that does not give user feedback that maps were unchanged b/c they were not collector ready)

tschwartzman commented 3 years ago

need to correct the typekeyword/typekeywords (should be plural) in commented sample queries

Example query which would only update maps currently enabled for Collector

webmap_search_query = "title:Hydrant AND typekeywords:'Collector'"

Example query which would update maps currently enabled for Field Maps

webmap_search_query = "title:Hydrant AND NOT typekeywords:'FieldMapsDisabled'"

Maybe it's overkill but perhaps in the comments cell can mention this is following agol/portal query guidelines (include link to advanced query doc? https://doc.arcgis.com/en/arcgis-online/reference/advanced-search.htm which oddly does not include mention of searching with typekeywords!) and they can test their query in their portal to make sure it comes back with what they are expecting.