function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BAGELBAGEL 

Update records with Master-Detail type problem in API8.0

I query a children dataset with parent id (master-detail datatype) as one of the columns using API 8.0. When I try to update the dataset, it gives error as the following:

{errors:{fields:Name,Opportunity__c, message:"Unable to create/update fields: Name, Opportunity__c. Please check the security settings of this field and verify that it is read/write for your profile.', statusCode:'INVALID_FIELD_FOR_INSERT_UPDATE',},id:null,success:'false',}

but it was working when I use API 7.0. Any clue anyone? Thanks


benjasikbenjasik
so you are trying to reparent a child?  Is it master-detail or lookup?
ckirklenckirklen

I am having this problem, and i am trying to re-parent a child object.

The child object is called Referral__c, and its parent is an Account.

A Referral is upserted into salesforce even before its Account is known - in that case, its parent is a special lost-and-found Account.

Once things outside of salesforce happen and a Referral's true Account is identified, an upsert is done to change the Account__c parent field in the Referral__c object so that the Referral will be child to the correct Account.

When i try this via the API, it returns INVALID_FIELD_FOR_INSERT_UPDATE, along with the message "Attempting to update (as part of an upsert) parent field Account__c with new value..."

But that's exactly what i need to do.  The Referral object also has another object that has a lookup relationship to Referral, so simply deleting the referral and recreating it with the new Account__c designaton isn't an option.

Any suggestions/recommendations?  I can't find anything in the online docs that says you can't do this.

SuperfellSuperfell
Just like the UI, you can't change the parent of an object that's a master-detail relationship to the parent. If you need to be able to change this, then you'd need to use a lookup relationship instead.
ckirklenckirklen

Rats - i was afraid of that.  It was originally a lookup relationship, but since the custom object had other objects hanging off it (via lookup relationships), we had hoped to let the master-detail relationship drag the custom object around without having to explicitly manage its ownership, thus controlling visibility to the various sales reps.

Thanks for the clarification; the doc doesn't explicitly state that a child in a master-detail relationship can't be reparented.  Wish it had (or that i had seen it if it does say that) so i could have avoided going down that road.

I appreciate your help, though!

TikiTiki
Hi,

I am not a developer, but i do have a similar problem in one of our implementations here. We turned to a Master-Detail relationship for two of our objects just so we could enforce sharing/access to the child records based on sharing settings of the parent.

We have instances wherein the child records need to be transferred to another parent. Why is it that the Master-Detail field cannot be edited? Could you please clarify?