<?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: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708589#M27750</link>
    <description>&lt;P&gt;Thanks, that's a tricky one then... My next thought would be to really dive into why your simple Append isn't working.&amp;nbsp; This script might help highlight any missing fields, or fields where the type / length don't match. Also keep an eye out for aliases that might match even if the underlying field doesn't.&lt;/P&gt;&lt;P&gt;Although maybe Append with attachments only works if there is a perfect schema match, and even a very careful manual field map won't fix this.&lt;/P&gt;&lt;P&gt;You could also look into the Export Attachments and Add Attachments GP tool, and just handle them separately from the features.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

target = r"URL or TOC layer name for new layer"
source = r"URL or TOC layer name for old layer"


def validate_append_schema(target_layer, source_layer):
    # Map field names to their properties for both layers
    def get_field_map(layer):
        return {f.name.upper(): f for f in arcpy.ListFields(layer) 
                if f.type not in ["OID", "Geometry"]}

    target_fields = get_field_map(target_layer)
    source_fields = get_field_map(source_layer)
    
    issues = []

    # Check for fields in Source that are missing in Target
    for name, f in source_fields.items():
        if name not in target_fields:
            issues.append(f"MISSING: Field '{name}' exists in Source but not in Target.")
        else:
            # Check for type mismatches
            t = target_fields[name]
            if f.type != t.type:
                issues.append(f"TYPE MISMATCH: '{name}' is {f.type} in Source, but {t.type} in Target.")
            
            # Check for length mismatches (relevant for text fields)
            if f.type == "String" and f.length &amp;gt; t.length:
                issues.append(f"LENGTH EXCEEDED: '{name}' length {f.length} exceeds target {t.length}.")

    # Check for fields in Target that might be required but are empty/not provided
    for name, f in target_fields.items():
        if name not in source_fields and f.required:
            issues.append(f"REQUIRED FIELD: '{name}' is required in Target but missing in Source.")

    return issues

# --- Implementation ---
report = validate_append_schema(target, source)

if not report:
    print("Schema check passed! Safe to append.")
else:
    print("Schema mismatch detected:")
    for issue in report:
        print(f" - {issue}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jun 2026 13:43:08 GMT</pubDate>
    <dc:creator>BrennanSmith1</dc:creator>
    <dc:date>2026-06-17T13:43:08Z</dc:date>
    <item>
      <title>Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706861#M27731</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here goes my journey, any help will be immensely appreciated.&lt;/P&gt;&lt;P&gt;The task I’ve got is to transfer c.2000 records from one hosted feature layer to another. The source layer has become not fit for purpose, with redundant fields and lack of coherence. Instead, I have created a new GDB on ArcGIS Pro with a Feature Class and a related Table which then I published to ArcGIS Online, to populated with records and attachments from the source AGOL layer (Note: the source layer does not have a related table. This was created just for the new layer as it seems the most robust way to handle multiple monitoring visits to each record).&lt;/P&gt;&lt;P&gt;So, I published my layer and table (with a relationship established of one-to-many) and I went on to heavily customise the attribute behaviour on the Form Designer of Map Viewer using a variety of Arcade Expressions. So far, so good.&lt;/P&gt;&lt;P&gt;Next thing I did, and this is when things started to go wrong, was trying to populate my new feature layer with the records (and attachments) from the old one. I presumed that a simple Append tool where I specify in the environments to preserve GlobalIDs and Attachments would suffice. But not quite. That’s when I started getting schema related errors (WARNING 003414: dataset does not match schema and will not be appended). Technically a warning, not an error. But nothing appended so clearly it didn’t work.&lt;/P&gt;&lt;P&gt;The next thing I tried was to export the old feature class to a FGDB, which I downloaded and tried to append then onto my new Feature layer, but I continue to get the same error.&lt;/P&gt;&lt;P&gt;Finally, and I can’t remember how, I managed to transfer (or copy and paste) records across by losing the GlobalID. This is a problem as I need to transfer attachments as well. So I’ve tried a number of things from creating dummy GlobalID fields so I could join the value somehow and use it to bring in attachments separately; created middle-step feature classes where I would try to clean any schema related issues with the Append tool, etc.&lt;/P&gt;&lt;P&gt;So, none of this worked, and I then also got the error message ERROR 003340: The target dataset must have a GlobalID field with a unique index.&lt;/P&gt;&lt;P&gt;At one point I managed somehow to bring in records without the attachments (or their original GlobalIDs) and then transferred attachments separately (using I believe ObjectIDs in one way or another) but with a very odd result: while in general about half the records should have attachments (maybe one or two, four at most), the result I experienced was that most records had zero attachments and some of them had MANY (starting with one, two or few more but for a few records escalating to 10+ then 100+ attachments with the biggest number being over 400 attachments for a single record).&lt;/P&gt;&lt;P&gt;I ultimately turned to Copilot and ChatGPT and as per after going through a series of hoops I ended up where I started. One thing worth mentioning was how it pointed me to creating a GlobalID via geoprocessing tool (Add Global ID) rather than a manually creating a GUID field called Global ID. It suggested that under the layer properties/indexes, I should be able to see Global ID having unique values, but this has been so far impossible. The Unique value for the GlobalID field (regardless of how I create it) is No.&lt;/P&gt;&lt;P&gt;If you’ve managed to read through my stream of consciousness, is there anything in my process that resonates and is there any support you can offer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance : )&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 18:06:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706861#M27731</guid>
      <dc:creator>RafaeldePedro</dc:creator>
      <dc:date>2026-06-08T18:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706940#M27732</link>
      <description>&lt;P&gt;Biggest thing that sticks out is:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;WARNING 003414: dataset does not match schema and will not be appended&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Did you try using the Append tool's field map option to assign the fields correctly? What you can also try is downloading the original data as a FGDB, doing the data design in another FGDB, appending the old data into the new schema, then publishing&amp;nbsp;&lt;EM&gt;that&lt;/EM&gt; as your service. That way you can check the validity of your data before it has to deal with ArcGIS Online.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 17:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706940#M27732</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2026-06-08T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706987#M27733</link>
      <description>&lt;P&gt;Thank you. I have actually tried that as well just before I posted my issue. So originally I had been trying to append it to the Hosted Feature Layer and then just to try other things I did the same but appending it to the FGDB originally created to publish the target Hosted Feature Layer, if that makes sense, but then I got the message&amp;nbsp;&lt;EM&gt;ERROR 003340: The target dataset must have a GlobalID field with a unique index.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 20:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706987#M27733</guid>
      <dc:creator>RafaeldePedro</dc:creator>
      <dc:date>2026-06-08T20:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706989#M27734</link>
      <description>&lt;P&gt;Also, when using the append tool, because I was aware of the schema warnings, I selected the option to map fields manually (those that were the same type and even the same name and should be of no concern) and even not mapping any field at all but it never worked, due to either the warning 003414 or the error 003340&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2026 20:41:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1706989#M27734</guid>
      <dc:creator>RafaeldePedro</dc:creator>
      <dc:date>2026-06-08T20:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708152#M27744</link>
      <description>&lt;P&gt;You can't have a unique index in a file geodatabase, only enterprise and mobile geodatabases. Can you please clarify / check a few things:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The existing hosted feature layer is just one layer with attachments enabled&lt;/LI&gt;&lt;LI&gt;The new hosted feature layer is one layer and one related (1:M) table&lt;/LI&gt;&lt;LI&gt;In your new schema, are the attachments supposed to go into the feature layer, or the related table?&lt;/LI&gt;&lt;LI&gt;Are you sure attachments have been enabled on the target layer?&lt;/LI&gt;&lt;LI&gt;Have you set the environment variable "Maintain Attachments" to True?&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 15 Jun 2026 14:35:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708152#M27744</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2026-06-15T14:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708563#M27749</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/39515"&gt;@BrennanSmith1&lt;/a&gt;&amp;nbsp;I didn't know that, thank you. I will keep playing with it and see how far I get now that I know this. To answer your points:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The existing hosted feature layer is just one layer with attachments enabled &lt;STRONG&gt;YES&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;The new hosted feature layer is one layer and one related (1:M) table &lt;STRONG&gt;YES&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;In your new schema, are the attachments supposed to go into the feature layer, or the related table? &lt;STRONG&gt;Into the Feature Layer. Nothing needs to go to the related table in this process. The table is available for future records when monitoring the same feature on different, repeat surveys.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Are you sure attachments have been enabled on the target layer? &lt;STRONG&gt;YES&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Have you set the environment variable "Maintain Attachments" to True? &lt;STRONG&gt;YES&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 17 Jun 2026 11:15:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708563#M27749</guid>
      <dc:creator>RafaeldePedro</dc:creator>
      <dc:date>2026-06-17T11:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Migrating Hosted Feature Layer with Attachments and Related Table – GlobalID / Append Issues</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708589#M27750</link>
      <description>&lt;P&gt;Thanks, that's a tricky one then... My next thought would be to really dive into why your simple Append isn't working.&amp;nbsp; This script might help highlight any missing fields, or fields where the type / length don't match. Also keep an eye out for aliases that might match even if the underlying field doesn't.&lt;/P&gt;&lt;P&gt;Although maybe Append with attachments only works if there is a perfect schema match, and even a very careful manual field map won't fix this.&lt;/P&gt;&lt;P&gt;You could also look into the Export Attachments and Add Attachments GP tool, and just handle them separately from the features.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

target = r"URL or TOC layer name for new layer"
source = r"URL or TOC layer name for old layer"


def validate_append_schema(target_layer, source_layer):
    # Map field names to their properties for both layers
    def get_field_map(layer):
        return {f.name.upper(): f for f in arcpy.ListFields(layer) 
                if f.type not in ["OID", "Geometry"]}

    target_fields = get_field_map(target_layer)
    source_fields = get_field_map(source_layer)
    
    issues = []

    # Check for fields in Source that are missing in Target
    for name, f in source_fields.items():
        if name not in target_fields:
            issues.append(f"MISSING: Field '{name}' exists in Source but not in Target.")
        else:
            # Check for type mismatches
            t = target_fields[name]
            if f.type != t.type:
                issues.append(f"TYPE MISMATCH: '{name}' is {f.type} in Source, but {t.type} in Target.")
            
            # Check for length mismatches (relevant for text fields)
            if f.type == "String" and f.length &amp;gt; t.length:
                issues.append(f"LENGTH EXCEEDED: '{name}' length {f.length} exceeds target {t.length}.")

    # Check for fields in Target that might be required but are empty/not provided
    for name, f in target_fields.items():
        if name not in source_fields and f.required:
            issues.append(f"REQUIRED FIELD: '{name}' is required in Target but missing in Source.")

    return issues

# --- Implementation ---
report = validate_append_schema(target, source)

if not report:
    print("Schema check passed! Safe to append.")
else:
    print("Schema mismatch detected:")
    for issue in report:
        print(f" - {issue}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2026 13:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/migrating-hosted-feature-layer-with-attachments/m-p/1708589#M27750</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2026-06-17T13:43:08Z</dc:date>
    </item>
  </channel>
</rss>

