0

I am using the REST API to write a set of nested records to a Salesforce developer org. I can successfully run the sample on this help page and can also write a custom object record with no nested children. What I cannot do is write a record with children nested in it. The error I get reports an INVALID_FIELD with message "No such column 'Areas__r' on sobject of type Job__c". Here's a cut down version of the JSON I am sending through:

{"records": [
    {
        "Areas__r": {
            "records": [
                {
                    "attributes": {
                        "referenceId": "ref1a",
                        "type": "Area__c"
                    },
                    "name": "some area"
                }
            ]
        },
        "Job_details__c": "Some job details",
        "attributes": {
            "referenceId": "ref1",
            "type": "Job__c"
        },
        "custom_field__c": "some custom field value"
    }
]}

Note that I have also tried replacing "Areas__r" with "Areas", "Areas__c", "Area__c". Still get the same problem. Area__c has a master detail relationship to Job__c.

2
  • What is the child relationship name for the MD relationship?
    – Coffee
    Apr 19, 2016 at 4:50
  • are you able to execute select id, (select name from areas__r) from job__c ? Apr 19, 2016 at 5:51

1 Answer 1

2

Refer to Understanding Relationship Names

JSON that you have provided is valid.

Goto custom object definition Area and make sure that

Plural Label    Areas

This name + '__r' will be used as relationship name for parent object

just in case make sure that you are using right service:

salesforce.com/services/data/v35.0/composite/tree/Job__c/
2
  • Thanks Ilya. Now working! So, my plural label was actually "Sch 34 Areas" and the custom object name is area__c. Turned out I needed to make the nested record name "sch_34_areas__r" and it works!!
    – donmac23
    Apr 19, 2016 at 23:10
  • But this does not work for nested creation of 2 new elements, does it?
    – Tobonaut
    May 4, 2017 at 8:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .