You need to sign in to do that
Don't have an account?
Help with Error Handling
I receive the following error when I try to merge 2 contact records: INVALID_FIELD_FOR_INSERT_UPDATE, Contact: bad field names on insert/update call: Comps__r:
The records the I am trying to merge are generated from the following 2 queries:
This will give me the childs in the merge...the record that will get deleted:
Contact childCon : [select Id, Acc_No_Part_1__c, Acc_No_Part_2__c, MergeMasterID__c, (select Id, Contact__r.MergeMasterId__c, External_ID__c from Comps__r) from Contact where Id IN :childCons)]
This gets me the parents:
(Contact masterCon : [select Id, Acc_No_Part_1__c, Acc_No_Part_2__c, MergeMasterID__c, (select Id, Contact__c, Contact__r.MergeMasterId__c, External_ID__c from Comps__r) from Contact where Id IN :masterConSet])
Before I can merge them I have to manipulate the child records found Camps__r. Once those updates are done I run a merge statement.
I think the error happens only when the Child Contact does not have any values in Comps__r. My code should be handling that scenario...In other words I use if statements to test if there are records in Comps__r, and if there is isn't then I have code to handle it differently.
When the child contact has records in comps__r then everything works ok.
The other posts that I have found related to this message are not helping, and the definition for the message in docs seems to be way off the mark:
INVALID_FIELD_FOR_INSERT_UPDATE
You can't combine a person account record type change with any other field update.
So, I am stumped at this point.
I solved this issue by not relying on SOQL parent-to-Child queries. Instead, I built a map: map<Id, List<Comp__c>>
which is what my originnal plan was but has held back by another strange error about the selectivity of my query...attributed to the large amount of records in that object. I got help and support to index a field for me and everything seems to be ok now.