0

Using Salesforce Mobile SDK 7.2 for iOS with Swift 5. Attempting to syncUp an Opportunity Line Item that has been updated on the device results in the error:

errorCode = "INVALID_FIELD_FOR_INSERT_UPDATE";
fields = ( OpportunityId ); message = "Unable to create/update fields: OpportunityId. Please check the security settings of this field and verify that it is read/write for your profile or permission set.";

OpportunityId is not in the child update field list. Is there a work around for OpportunityLineItem records? Can't reparent.

Here's the definition of my syncUp:

{
    "syncName": "syncUpOpps",
    "syncType": "syncUp",
    "soupName": "opportunity",
    "target": {
        "iOSImpl": "SFParentChildrenSyncUpTarget",
        "childrenCreateFieldlist": [
            "Id",
            "OpportunityId",
            "PricebookEntryId",
            "Product__c",
            "Quantity",
            "UnitPrice"
        ],
        "parentCreateFieldlist": [
            "Id",
            "Name",
            "AccountId",
            "CloseDate",
            "Description"
        ],
        "childrenUpdateFieldlist": [
            "Id",
            "Product__c",
            "Quantity",
            "UnitPrice"
        ],
        "parentUpdateFieldlist": [
            "Id",
            "Name",
            "CloseDate",
            "Description"
        ],
        "parent": {
            "idFieldName": "Id",
            "sobjectType": "Opportunity",
            "modificationDateFieldName": "LastModifiedDate",
            "soupName": "opportunity"
        },
        "relationshipType": "MASTER_DETAIL",
        "type": "rest",
        "modificationDateFieldName": "LastModifiedDate",
        "children": {
            "parentIdFieldName": "OpportunityId",
            "idFieldName": "Id",
            "sobjectType": "OpportunityLineItem",
            "modificationDateFieldName": "LastModifiedDate",
            "soupName": "opportunityLineItem",
            "sobjectTypePlural": "OpportunityLineItem"
        },
        "idFieldName": "Id"
    },
    "options": {"mergeMode":"OVERWRITE"}
}

Thanks in advance for any ideas, suggestions, questions, etc.

1

Did you check that the field is indeed writable for the profile or permission set? See the discussion here: https://developer.salesforce.com/forums/?id=906F00000008qFMIAY

| improve this answer | |
  • Hi, at least according to the syncup configuration listed above, the OpportunityId (the field referenced in the error message) is not being passed in the update. So I'm not sure why the sync would be complaining about that field. – aspjim Jan 9 at 17:25
  • Hi, any idea why the syncUp is sending the OpportunityId for the OpportunityLineItem update? The OpportunityId is not defined in childrenUpdateFieldlist. The creation of OpportunityLineItems works correctly. It is the update of the OpportunityLineItem that is failing. I have checked the permissions on the OpportunityLineItem and they are set correctly for the user to create and edit the object. – aspjim Jan 28 at 20:54
0

I have just experienced the same problem. This is caused by a bug in

[SFParentChildrenSyncUpTarget buildRequestForRecord]

There is a parameter called useParentIdReference which is true only when the object is being created. Unfortunately, even if it is false, the parent reference is still passed to the request. Even if the reference does not change, passing it to the request will cause the request to fail with the mentioned error.

It seems the only way to fix that is to create a subclass, override that method and apply a fix.

Or enable reparenting (even if not needed).

| improve this answer | |

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.