Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting CKRecord: Record delete would violate validating reference, rejecting update

I simply try to delete CKRecord. Before I assigned it as a parent and reference to another ckrecord like this:

    let rID = CKRecordID(recordName: territory.identifier, zoneID: territory.recordZoneID)
    let record = CKRecord(recordType: "Territory", recordID: rID)

    if let territoryGroup = territoryGroup {
        let recordID = CKRecordID(recordName: territoryGroup.identifier, zoneID: CloudAssistant.shared.zone.zoneID)
        record.parent = CKReference(recordID: recordID, action: .none)
        record["territoryGroup"] = CKReference(recordID: recordID, action: .none)
    }

and the error is following:

"Error deleting record : Record delete would violate validating reference ([C1A31F1D-914F-4007-8C8B-73FC0503C798, ...]), rejecting update"

This was intended to delete record without deleting its child records, and this is why I set there action .none instead of .deleteSelf.

What is wrong?

The same in dashboard:

enter image description here

For corresponding reference record there is a good setup:

enter image description here

As you can see delete Self is not selected. Am I missing something? For me, it should delete it without problem.

like image 656
Bartłomiej Semańczyk Avatar asked Oct 27 '25 14:10

Bartłomiej Semańczyk


1 Answers

I ran into this same error when I set the parent of the record with setParent(parentRecordID) and also created a CKReference with .none. It looks like if you set the parent, you have to use .deleteSelf on the standard reference. However, from what I can tell, setting the parent is only necessary if you want to use CKShare. I wrote more about it here.

like image 75
blwinters Avatar answered Oct 29 '25 06:10

blwinters