3

From the documentation here is what my body looks like for the request.

I'm trying to create one parent (SEO__CSEO_Survey__c) and then one child (SEO__CSEO_Survey_Question__c) in a master-detail relationship.

{
"records":[{
    "attributes":{"type":"SEO__CSEO_Survey__c","referenceId":"survey"},
    "Name":null,
    "SEO__Survey_Welcome_Heading__c":null,
    "SEO__Welcome_Text__c":"Test444",
    "SEO__CSEO_Survey_Question__c":{
        "records": [{
           "SEO__Order__c":null,
           "SEO__Question__c":"q1",
           "attributes":{"type":"SEO__CSEO_Survey_Question__c","referenceId":"question0"}
        }]
     }
}]
}

The error

[ { "message": "No such column 'SEO__CSEO_Survey_Question__c' on sobject of type SEO__CSEO_Survey__c", "errorCode": "INVALID_FIELD" } ]

What I don't understand from the docs is on line 9 of the example code. The example uses "Contacts", as if that was a field on Account, which it is not, correct?

Instead of naming my key SEO__CSEO_Survey_Question__c, what should it be?

Update: Solved thanks to Adrian. Here is a screenshot of my relationship if someone has a problem understanding the solution.

enter image description here

2

If you want to get the child relationship name, you can use this script:

for (ChildRelationship relation : SObjectType.SEO__CSEO_Survey__c.getChildRelationships())
    if (relation.getChildSObject() == SEO__CSEO_Survey_Question__c.sObjectType)
        system.debug(relation.getRelationshipName());

The relationship name should be printed exactly as you need to specify it. Usually it's plural, and always ends in __r for custom relationships. So the expected value would be: SEO__CSEO_Survey_Questions__r.

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.