0 Replies
      Latest reply on Jul 24, 2019 12:38 PM by ShinehahGnolaum
      ShinehahGnolaum Level 1 Level 1 (0 points)

        I am getting an error from CloudKit saying:

         

        Error saving record <CKRecordID: 0x107b376c0; recordName=99A37C98-35AD-49CC-A6F6-4C282A305E4E, zoneID=_defaultZone:__defaultOwner__> to server: record to insert already exists

         

        from this code:

         

            privateDatabase.save(privateRecord) {
               
                record, error in
               
                if error != nil {
                   
                    print("Error saving record:", error!.localizedDescription)
                   
                } else {
                   
                    print("Record saved successfully.")
                   
                }
               
            }
        
        

         

        Here is what the debug window shows:

         

        Record saved successfully.

        Error saving record: Error saving record <CKRecordID: 0x105e7b270; recordName=48C6B352-6699-46E3-B453-AA3C473A9ED9, zoneID=_defaultZone:__defaultOwner__> to server: record to insert already exists

        Record saved successfully.

        Error saving record: Error saving record <CKRecordID: 0x107e9f3f0; recordName=2C4CE9EF-7129-4330-A128-B96D4A8994BE, zoneID=_defaultZone:__defaultOwner__> to server: record to insert already exists

        Record saved successfully.

        Error saving record: Error saving record <CKRecordID: 0x106271930; recordName=F9DEEA9F-3763-40D5-BE5F-F8EFAD99E44C, zoneID=_defaultZone:__defaultOwner__> to server: record to insert already exists

        Record saved successfully.

        Error saving record: Error saving record <CKRecordID: 0x107b376c0; recordName=99A37C98-35AD-49CC-A6F6-4C282A305E4E, zoneID=_defaultZone:__defaultOwner__> to server: record to insert already exists

         

        Where it says "Record saved successfully." came from another print statement I don't show, that doesn't matter.

         

        As you see I caused the code to execute repeatedly through the user interface of my project, and the recordName value is different each time. I see no indication in my schema in CloudKit that any fields require a unique value except recordName, and as you see the recordName values are each different.

         

        Here are the system fields of my record type:

         

            Field Name | Field Type | Indexes

            ----------       ----------      -------

            recordName Reference    Queryable

            createdBy    Reference    None

            createdAt     Date/Time   Sortable

            modifiedBy   Reference   None

            modifiedAt    Date/Time   None

            changeTag    String       None