"Only shared zones can be accessed in the shared DB"

I am using fetchAllRecordZones to get the zones in sharedCloudDatabase.


Using this, I can successfully query the zones to get the records in them from the sharedCloudDatabase. I can also make a subscription to the sharedCloudDatabase.


However, I can't write back into the sharedCloudDatabase using the ZoneID I retrieved with fetchAllRecordZones!


<CKError 0x280d24390: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = E33E6EA8-824A-4BBB-9455-5DD58091C696; container ID = "iCloud.com.my-id"; partial errors: {

9E2B5947-536F-4DBB-8473-0902428AFA0E-67855-0000882339B04A4B:(SharedZone:_947ea1c9f3aeeb7dca58149ad40080e9) = <CKError 0x280d25890: "Invalid Arguments" (12/2006); server message = "Only shared zones can be accessed in the shared DB"; uuid = E33E6EA8-824A-4BBB-9455-5DD58091C696>

}>


But I am accessing a shared zone using the shared DB. I can confirm that SharedZone:_947ea1c9f3aeeb7dca58149ad40080e9 is the zone that is in my sharedCloudDatabase that I am trying to write to in Dashboard.


So I'm not sure what to do to get my sharee to be able to edit the shared document 😟


I've tried several things, one of those is using the privateCloudDatabase, but I get "PrivateDB can't be used to access another user's zone" which makes sense and can at least confirm my zone is legit.


Any help?!

Hello!


In addition to using correct DB (which is shared) you'll need to create new record with correct zone id.


For example, when I am adding new record to shared DB related to some parent record, I generate CKRecord.ID for it using zone id from previously fetched record by getting it's zone id:


func newIdentifier(withZoneFrom record: CKRecord? = nil) -> CKRecord.ID {
        if let record = record {
            return CKRecord.ID(recordName: UUID().uuidString, zoneID: record.recordID.zoneID)
        }
}


And it works fine for me. If you'll provide code example how you create new record I will be able to give you more advice.

"Only shared zones can be accessed in the shared DB"
 
 
Q