1

I have 2 custom objects: custObj1 & custObj2. It is a one:Many relationship between the 2. I have set up a lookup relationship under custObj2. Wallet_Address__c is on both objects and is the external id on custObj1

I am trying to get the Wallet_Address__c from custObj1 in my PATCH call to insert a new record in to custObj2 with the same value.

PATCH https://mydomain.my.salesforce.com/services/data/v53.0/sobjects/custObj2/Unique_Address__c/custObj2ExternalId

{
    "Amount__c":"2",
    "Contract_Address__c":"someValue",
    "custObj1__r":{"Wallet_Address__c":"someExternalId"}
}

but I am receiving the below response.

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

I have tried changing the relationship to master-detail and back. Nothing seems to be working. I suspect in need the actual relationship name to reference in the call but not sure. Any ideas?

UPDATE - I am trying to implement Upserting Records and Associating with an External ID which is found here.

4
  • Maybe this might help?
    – sfdcfox
    Commented Jan 2, 2022 at 2:56
  • I appreciate the help, but I am trying to implement Upserting Records and Associating with an External ID found here. It is the exact usecase I am going for. I will try the solution in the link you provided. Thank you.
    – YouthDev
    Commented Jan 2, 2022 at 3:10
  • Welcome to Salesforce Stack Exchange (SFSE)! In the text of your question you say "PATCH" but in the code you shared you have POST. For upsert you ovbviously want PATCH. I know you may have tried different things and/or copied & pasted the wrong thing - I just want to ensure that you have tried PATCH.
    – Moonpie
    Commented Jan 2, 2022 at 3:32
  • Thanks for the catch @Moonpie. I meant to put PATCH. Good eye! I did resolve my issue and put my answer in the comment.
    – YouthDev
    Commented Jan 2, 2022 at 3:35

1 Answer 1

3

I have figured out my issue.

I was trying to reference the object name in the __r instead of the actual name of the relationship I created within custObj2. When using the name of the relationship and changing it from __c to __r, it worked.

{
    "Amount__c":"2",
    "Contract_Address__c":"someValue",
    "Wallet_Address__r":{"Wallet_Address__c":"someExternalId"}
}

In the above, Wallet_Address__r is actually Wallet_Address__c in custObj2

You must log in to answer this question.

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