<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Turning off editing field by field? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576677#M63212</link>
    <description>&lt;P&gt;Thank you, that worked great!&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jan 2025 00:20:35 GMT</pubDate>
    <dc:creator>MatthewStull1</dc:creator>
    <dc:date>2025-01-17T00:20:35Z</dc:date>
    <item>
      <title>Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576641#M63207</link>
      <description>&lt;P&gt;I have a hosted feature layer with 24 fields in it.&amp;nbsp; I want to turn off editing on all of the fields except one.&amp;nbsp; Do I really need to go one at a time and turn off the editing field by field for the other 23?&amp;nbsp; &amp;nbsp;I'm doing this in the "Data" tab "Fields" view of my layer's information page.&amp;nbsp; Is there a quicker way to do this?&amp;nbsp; If not, that is not great.&amp;nbsp; Is there a way for me to easily turn off field by field editing in the Map Viewer (I don't think there is)?&amp;nbsp; Anyway, if I do have to go field by field and turn off editing, that's not great and I will submit that as an enhancement idea.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 22:41:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576641#M63207</guid>
      <dc:creator>MatthewStull1</dc:creator>
      <dc:date>2025-01-16T22:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576657#M63209</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/304962"&gt;@MatthewStull1&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can create a form in Map Viewer. Select which fields to add to the form by dragging and dropping them on to the canvas. In your case, you can simply add 1 field to the form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="EmilyGeo_1-1737070328565.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/123514iBC5FA53FEE3BB5E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="EmilyGeo_1-1737070328565.png" alt="EmilyGeo_1-1737070328565.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 23:34:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576657#M63209</guid>
      <dc:creator>EmilyGeo</dc:creator>
      <dc:date>2025-01-16T23:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576670#M63211</link>
      <description>&lt;P&gt;I usually script this type of thing up if it's something I'm doing more than once - particularly when I have a hosted feature layer with a large number of views hanging off of it, and I need to modify all of the views.&amp;nbsp; Below is an example of code where I disable editing on all fields except two named lifecycle_status and review_notes.&amp;nbsp; I modify the two constants at the top for the view's Item ID and the layer/table indices that should be editable.&lt;/P&gt;&lt;P&gt;There are a couple improvements that could be made to this; the field property updates could be bundled together into a single call to update_definition, that would make it quicker, and the field names that remain editable could be put into a list at the top of the code rather than being hardcoded in the middle.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;VIEW_ITEM_ID = "your_item_id_here"
EDIT_DATASET_IDX_LIST = [0]

from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

# Connect to the view.
gis = GIS("home")
content = gis.content
view_item = content.get(VIEW_ITEM_ID)
if view_item is None:
    raise Exception("View item not found.")
view_flc = FeatureLayerCollection.fromitem(view_item)

# Iterate through each of the layers and tables.
view_datasets = view_flc.layers + view_flc.tables
for view_dataset in view_datasets:
    # Determine whether we want any editable fields.
    view_dataset_idx = view_dataset.properties["id"]
    dataset_editable = view_dataset_idx in EDIT_DATASET_IDX_LIST
    
    # Iterate through the fields, updating those that are editable and not related to approval.
    view_dataset_manager = view_dataset.manager
    for field_def in view_dataset.properties["fields"]:
        if not field_def["editable"]:
            continue
        if dataset_editable and "lifecycle_status" in field_def["name"]:
            continue
        if dataset_editable and "review_notes" in field_def["name"]:
            continue
        
        # Put together a dictionary for the manager update call.
        def_update = {
            "fields": [
                {
                    "name": field_def["name"],
                    "editable": False
                }
            ]
        }
        view_dataset_manager.update_definition(def_update)

print("Finished.")&lt;/LI-CODE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 23:59:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576670#M63211</guid>
      <dc:creator>MobiusSnake</dc:creator>
      <dc:date>2025-01-16T23:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576677#M63212</link>
      <description>&lt;P&gt;Thank you, that worked great!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 00:20:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1576677#M63212</guid>
      <dc:creator>MatthewStull1</dc:creator>
      <dc:date>2025-01-17T00:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695907#M68401</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115587"&gt;@MobiusSnake&lt;/a&gt;&amp;nbsp;This is great was just looking at this today thinking how am I going to turn off 4,000+ fields.&lt;/P&gt;&lt;P&gt;I wish we could turn off whole layers like you can for geometry.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Right here I can turn off all geo why can't I also turn off all editing using a layer list vs forcing me to do each and every field.&amp;nbsp; Not very scalable here.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DougBrowning_0-1776107411865.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/151013i52533E7B5A55326E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DougBrowning_0-1776107411865.png" alt="DougBrowning_0-1776107411865.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is there any setting at the layer level or is it field only?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 19:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695907#M68401</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2026-04-13T19:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695946#M68404</link>
      <description>&lt;P&gt;I also updated your script to have it turn whole layers off in one config line and a list per layer telling only which fields to turn ON.&amp;nbsp; That was my use case.&amp;nbsp; Does it in a single call also.&lt;BR /&gt;&lt;BR /&gt;Works slick!&amp;nbsp; Did 37 layers 4,000 fields in a few mins.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# --- Configuration ------------------------------------------------------------
VIEW_ITEM_ID = "View Item ID"  # your view item id

# Turn OFF editing for ALL fields for these layer/table IDs (one call per layer/table).
FULLY_DISABLE_LAYER_IDS = [2,3,4]

# For these layer/table IDs, leave editing ON only for the listed fields.
# All other currently-editable fields will be turned OFF in a single call.
# 0 is Points and 1 is Field Visits
ALLOW_EDIT_FIELDS_BY_LAYER = {
    # Example:
    0: ["StreamName", "OfficeEvaluator"],
    1: ["ReasonNotSampled", "PDFgenerate"],
}

# Optional: For layers in this list, leave *only* GLOBAL_ALLOWED_FIELDS editable.
# (This preserves your original behavior where some layers keep a short allowlist.)
EDIT_DATASET_IDX_LIST = []  # e.g., layer 0 uses the global allowlist

GLOBAL_ALLOWED_FIELDS = []

# Behavior controls
CASE_SENSITIVE_FIELD_MATCH = False  # False means case-insensitive matching by field name
DRY_RUN = False                     # True = print intended changes, do NOT call update_definition

# --- Script -------------------------------------------------------------------
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection

def norm(name: str) -&amp;gt; str:
    return name if CASE_SENSITIVE_FIELD_MATCH else name.lower()

# Connect to the view item and get the layer collection
gis = GIS("Pro")
view_item = gis.content.get(VIEW_ITEM_ID)
if view_item is None:
    raise Exception(f"View item not found: {VIEW_ITEM_ID}")
view_flc = FeatureLayerCollection.fromitem(view_item)

# Iterate through layers and tables
view_datasets = (view_flc.layers or []) + (view_flc.tables or [])

for ds in view_datasets:
    ds_props = ds.properties
    ds_id = ds_props.get("id")
    ds_name = ds_props.get("name", f"id:{ds_id}")
    fields = ds_props.get("fields", [])
    mgr = ds.manager

    # Decide the mode for this dataset
    # 1) Full disable list wins
    if ds_id in FULLY_DISABLE_LAYER_IDS:
        updates = []
        for f in fields:
            # Only touch fields that are currently editable
            if f.get("editable", False):
                updates.append({"name": f["name"], "editable": False})

        if updates:
            payload = {"fields": updates}
            if DRY_RUN:
                print(f"[DRY RUN] {ds_name} (id={ds_id}) -&amp;gt; disable ALL editable fields ({len(updates)}).")
            else:
                mgr.update_definition(payload)
                print(f"{ds_name} (id={ds_id}) -&amp;gt; disabled {len(updates)} editable fields in one call.")
        else:
            print(f"{ds_name} (id={ds_id}) -&amp;gt; no changes (no fields marked editable).")
        continue  # Done with this dataset

    # 2) Allow-only list per layer
    allow_only = None
    if ds_id in ALLOW_EDIT_FIELDS_BY_LAYER:
        allow_only = set(norm(n) for n in ALLOW_EDIT_FIELDS_BY_LAYER[ds_id])

    # 3) If not per-layer allowlist, check if this dataset is in your classic list
    #    that should keep only GLOBAL_ALLOWED_FIELDS editable.
    elif ds_id in EDIT_DATASET_IDX_LIST:
        allow_only = set(norm(n) for n in GLOBAL_ALLOWED_FIELDS)

    updates = []
    if allow_only is not None:
        # Turn OFF any editable field that is NOT in the allowlist.
        for f in fields:
            if not f.get("editable", False):
                continue
            if norm(f["name"]) in allow_only:
                # Leave it editable; no change required.
                continue
            updates.append({"name": f["name"], "editable": False})

    else:
        # Default behavior: if the dataset is not in any configured list,
        # do NOT change anything. If you prefer the old behavior (disable all),
        # uncomment the following to disable all editable fields by default:
        #
        # for f in fields:
        #     if f.get("editable", False):
        #         updates.append({"name": f["name"], "editable": False})
        pass

    # Apply (in one call) if there are updates
    if updates:
        payload = {"fields": updates}
        if DRY_RUN:
            print(f"[DRY RUN] {ds_name} (id={ds_id}) -&amp;gt; disable {len(updates)} fields not in allowlist.")
        else:
            mgr.update_definition(payload)
            print(f"{ds_name} (id={ds_id}) -&amp;gt; disabled {len(updates)} fields in one call.")
    else:
        print(f"{ds_name} (id={ds_id}) -&amp;gt; no changes required.")

print("Finished.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 20:34:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695946#M68404</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2026-04-13T20:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Turning off editing field by field?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695948#M68405</link>
      <description>&lt;P&gt;Note this does not stop them from just using the attribute table in the map (which is what most of our users do).&amp;nbsp; They can get around all of it in Pro also.&lt;/P&gt;&lt;P&gt;Safest way is a view as listed below.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2026 20:36:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/turning-off-editing-field-by-field/m-p/1695948#M68405</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2026-04-13T20:36:07Z</dc:date>
    </item>
  </channel>
</rss>

