0

This is the exact error : from smartSync SFLogger

ERROR com.salesforce : Sync type:syncUp id:6 FAILED cause:Server call for sync up failed error:Error Domain=CSFNetworkErrorDomain Code=400 "Unable to create/update fields: XXXX_C__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set." UserInfo={NSLocalizedFailureReason=INVALID_FIELD_FOR_INSERT_UPDATE, isAuthenticationFailure=false, NSLocalizedDescription=Unable to create/update fields: XXXX_C__c. Please check the security settings of this field and verify that it is read/write for your profile or permission set., action=*}

Actually what I am trying to do :

I have SObject ClassA__c which is a parent I have another SObject ClassB__c which has field ClassA__c_ID as Master-Detail(ClassA__c)

Now when I create an object of type ClassB__c, it works fine , can create and sync its added and synced to salesForce

Now when I update some other independent field (Docket__c , Number(10, 0)) in the ClassB__c object and try to upsert and Sync using smartSync . It fails with that error mentioned above.

I believe it's happening because we have Master-Detail field in ClassB__c cause I have already verified, we have all the write/read access with the profile. How can we exclude Master-Detail field only while an update through smartSync but include while we create the new object.

0

Example Gist of Custom Sync Up target

I've experienced the same thing, and had to write a custom SyncUp target to resolve this issue. You extend the base SyncUp target, and then override whatever methods you need to override.

I only have experience with iOS, so I overrode this method:

- (void)updateOnServer:(NSString*)objectType
          objectId:(NSString*)objectId
            fields:(NSDictionary*)fields
   completionBlock:(SFSyncUpTargetCompleteBlock)completionBlock
         failBlock:(SFSyncUpTargetErrorBlock)failBlock

The fields argument is a dictionary that determines what value to set on what field when updating. The objectType argument is the metadata name (Account, OpportunityLineItem etc...) of the sObject that is currently being operated on.

When you override this method, check objectType to see if it is your sObject that has a Master/Detail relationship. If it is, make a new NSDictionary of fields and exclude the Master/Detail field that cannot change. Then you can call super updateOnServer with the new field argument so that the standard behavior resumes without the Master/Detail field present.

From there, you'll need to use syncUpWithTarget rather than plain syncUp to specify that your custom SyncUp target should be utilized.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.